getAllBalances

Squid's SDK provides a function to get the balance of every token we support by providing an address for each environment.

const squid = new Squid({
  baseUrl: "https://v2.api.squidrouter.com",
  integratorId: "squid-test"
});

await squid.init();

const allBalances = await squid.getAllBalances({
  chainIds: ["osmosis-1", 43114, 8453],
  evmAddress: "0x344b63c2BcB4B61765083735e8F49Bb203415a33",
  cosmosAddresses: [
    {
        address: "cosmos1awrua7e2kj69d7vn5qt5tccrhavmj9xajl58pw",
        chainId: "cosmoshub-4",
        coinType: 118
     }
  ]
})
// result:
// {
//   cosmos: [
//     {
//       balance: "676727870",
//       denom:
//         "ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1",
//       chainId: "osmosis-1",
//       decimals: 6
//     },
//     {
//       balance: "5987424",
//       denom: "uosmo",
//       chainId: "osmosis-1",
//       decimals: 6
//     }
//   ],
//   evm: [
//     {
//       balance: "2981435909446986",
//       symbol: "ETH",
//       address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
//       decimals: 18,
//       chainId: "8453"
//     },
//     {
//       balance: "788395441854562446",
//       symbol: "AVAX",
//       address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
//       decimals: 18,
//       chainId: "43114"
//     }
//   ]
// }

const evmBalances = await squid.getEvmBalances({
  userAddress: "0x344b63c2BcB4B61765083735e8F49Bb203415a33",
  chains: [1, 43114, 8453]
})

// result:
// [
//     {
//       balance: "41345097216001030",
//       symbol: "ETH",
//       address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
//       decimals: 18,
//       chainId: "1"
//     }, {
//       balance: "9424225",
//       symbol: "USDC",
//       address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
//       decimals: 6,
//       chainId: "1"
//     }, {
//       balance: "81435909446986",
//       symbol: "ETH",
//       address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
//       decimals: 18,
//       chainId: "8453"
//     }, {
//       balance: "788395441854562446",
//       symbol: "AVAX",
//       address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
//       decimals: 18,
//       chainId: "43114"
//     }
//   ]

const cosmos = await squid.getCosmosBalances({
  addresses: [
    {
      chainId: "cosmoshub",
      address: "cosmos1awrua7e2kj69d7vn5qt5tccrhavmj9xajl58pw",
      coinType: 118
    }
  ]
})
// result:
//  [
//    {
//       balance: "1804685",
//       denom: "uatom",
//       chainId: "cosmoshub-4",
//       decimals: 6
//     }
//   ]

Last updated