https://github.com/chainstacklabs/multiple-token-balance-javascript
Examples of how to retrieve multiple token balances.
https://github.com/chainstacklabs/multiple-token-balance-javascript
Last synced: 12 months ago
JSON representation
Examples of how to retrieve multiple token balances.
- Host: GitHub
- URL: https://github.com/chainstacklabs/multiple-token-balance-javascript
- Owner: chainstacklabs
- Created: 2022-05-30T13:28:29.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-16T00:27:10.000Z (about 2 years ago)
- Last Synced: 2025-03-27T06:11:54.708Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://chainstack.com/ultimate-guide-erc20-token-balance/
- Size: 1.01 MB
- Stars: 6
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# The ultimate guide to token balances

This repository contains code examples to obtain balances from multiple ERC20 tokens for a blockchain wallet.
Check out [the article in the Chainstack blog](https://chainstack.com/ultimate-guide-erc20-token-balance/) for a complete description of how to query balances.
## CLI app
The cli-app folder contains an app that can be used to query token balances from different blockchain protocols from the command line. Supported blockchains are: Ethereum, Binance Smart Chain, Avalanche and Polygon.
### CLI app requirements
**This application requires Node.js v15**
This app requires access to blockchain archive nodes via RPC. [Sign up with Chainstack](https://console.chainstack.com/user/account/create) to get access to multiple blockchain protocols.
In addition, it uses the APIs from [Etherscan](https://etherscan.io/), [Snowtrace](https://snowtrace.io/), [BscScan](https://bscscan.com/) and [PolygonScan](https://polygonscan.com/) so API keys for all those are also requred.
> Note: not all API keys are mandatory, just the ones from the blockchain protocol you'd use.
Both archive nodes endpoints and API keys must be configured in an .env file. Just enter the values in the `.env.example` file and rename it to `.env`.
```sh
ETH_ARCHIVE_NODE=
BNB_ARCHIVE_NODE=
AVA_ARCHIVE_NODE=
POLY_ARCHIVE_NODE=
ETHERSCAN_API_KEY=
SNOWTRACE_API_KEY=
BSCSCAN_API_KEY=
POLYSCAN_API_KEY=
```
### Installation and run
Install all dependencies with `npm i`. Start the CLI program with `node index.js`