chainstacklabs / multiple-token-balance-javascript

Examples of how to retrieve multiple token balances.

Home Page:https://chainstack.com/ultimate-guide-erc20-token-balance/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 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 to get access to multiple blockchain protocols.

In addition, it uses the APIs from Etherscan, Snowtrace, BscScan and PolygonScan 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.

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

About

Examples of how to retrieve multiple token balances.

https://chainstack.com/ultimate-guide-erc20-token-balance/


Languages

Language:JavaScript 98.7%Language:Shell 1.3%