{"id":18794508,"url":"https://github.com/chainstacklabs/ethereum-token-balances-javascript","last_synced_at":"2025-04-13T14:32:46.150Z","repository":{"id":43466824,"uuid":"328567997","full_name":"chainstacklabs/ethereum-token-balances-javascript","owner":"chainstacklabs","description":"Code samples to retrieve multiple Ethereum token balances from addresses using GraphQL, ethers.js, and web3.js libraries","archived":false,"fork":false,"pushed_at":"2023-04-11T20:56:50.000Z","size":62,"stargazers_count":22,"open_issues_count":0,"forks_count":11,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-27T06:11:59.721Z","etag":null,"topics":["balance","erc20","ethereum","retrieve-data","token"],"latest_commit_sha":null,"homepage":"https://chainstack.com/the-ultimate-guide-to-getting-multiple-token-balances-on-ethereum/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chainstacklabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-11T06:22:37.000Z","updated_at":"2024-05-12T05:07:19.000Z","dependencies_parsed_at":"2024-11-07T21:40:52.621Z","dependency_job_id":"07361fc4-bfdd-4a20-af4e-ff54913435d3","html_url":"https://github.com/chainstacklabs/ethereum-token-balances-javascript","commit_stats":null,"previous_names":["chainstacklabs/ethereum-token-balances-javascript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fethereum-token-balances-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fethereum-token-balances-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fethereum-token-balances-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chainstacklabs%2Fethereum-token-balances-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chainstacklabs","download_url":"https://codeload.github.com/chainstacklabs/ethereum-token-balances-javascript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248728225,"owners_count":21152181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["balance","erc20","ethereum","retrieve-data","token"],"created_at":"2024-11-07T21:29:38.646Z","updated_at":"2025-04-13T14:32:46.140Z","avatar_url":"https://github.com/chainstacklabs.png","language":"JavaScript","readme":"\u003cimg width=\"1200\" alt=\"Labs\" src=\"https://user-images.githubusercontent.com/99700157/213291931-5a822628-5b8a-4768-980d-65f324985d32.png\"\u003e\n\n\u003cp\u003e\n \u003ch3 align=\"center\"\u003eChainstack is the leading suite of services connecting developers with Web3 infrastructure\u003c/h3\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-ethereum/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Ethereum.svg\" /\u003e\u003c/a\u003e\u0026nbsp;  \n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-bnb-smart-chain/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/BNB.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-polygon/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Polygon.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-avalanche/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Avalanche.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/build-better-with-fantom/\"\u003e\u003cimg src=\"https://github.com/soos3d/blockchain-badges/blob/main/protocols_badges/Fantom.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  • \u003ca target=\"_blank\" href=\"https://chainstack.com/\"\u003eHomepage\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/protocols/\"\u003eSupported protocols\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://chainstack.com/blog/\"\u003eChainstack blog\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://docs.chainstack.com/quickstart/\"\u003eChainstack docs\u003c/a\u003e •\n  \u003ca target=\"_blank\" href=\"https://docs.chainstack.com/quickstart/\"\u003eBlockchain API reference\u003c/a\u003e • \u003cbr\u003e\n  • \u003ca target=\"_blank\" href=\"https://console.chainstack.com/user/account/create\"\u003eStart for free\u003c/a\u003e •\n\u003c/p\u003e\n\n# Retrieve multiple token balances on Ethereum\n\nThis repository contains code examples on how you can retrieve Ethereum tokens in bulk using:\n\n- GraphQL\n- Etherplex\n- web3.js BatchRequest\n\n## Quick start\n\nClone the repository:\n\n```sh\ngit clone https://github.com/chainstack/ethereum-token-balances.git\n```\n\nInstall  dependencies:\n\n```sh\nnpm ci\n```\n\n\u003e Use `npm ci` to launch a `clean install` of the dependencies, this will install the same version as in the `package.json` file.\n\nReplace the following values in the `constant.js` file to suit your use case:\n\n- `username` — your Ethereum node RPC username.\n- `password` — your Ethereum node RPC password.\n- `rpcEndpoint` — your Ethereum node RPC endpoint.\n- `bathEndpoint` — your Ethereum node RPC endpoint with authentication credentials.\n- `walletAddress` — the account address you want to query.\n- `ABI (Application Binary Interface)` - contract ABI with only the `balanceOf` function, remember to add the function calls you're planning to execute to the ABI constant.\n\nThen:\n\n## GraphQL\n\nGraphQL is a runtime natively supported by [Go Ethereum client](https://geth.ethereum.org). See also [GraphQL on Ethereum](https://chainstack.com/graphql-on-ethereum-availability-on-chainstack-and-a-quick-rundown/).\n\nRun:\n\n```bash\nnode graph\n```\n\nSample results:\n\n```json\n{\n  \"GameCredits\":\"1600000000000000000000 GAME\",\n  \"Swarm Fund\":\"0 SWM\",\n  \"Augur\":\"250684955559177177971383 REP\",\n  \"Tether\":\"52057527540802 USDT\",\n  \"DigixDAO\":\"122062000003 DGD\",\n  \"SingularDTV\":\"1809462 SNGLS\",\n  \"Veros\":\"0 VRS\",\n  \"Golem\":\"83169802320824576633066602 GLM\",\n  \"Circuits of Value\":\"0 COVAL\",\n  \"chrono tech\":\"0 TIME\",\n  \"Melon\":\"0 MLN\",\n  \"WeTrust\":\"0 TRST\",\n  \"iExec RLC\":\"1633118384742405 RLC\",\n  ...\n}\n```\n\n## Etherplex\n\n[Etherplex](https://github.com/pooltogether/etherplex) is a JavaScript library that makes use of the [multicall](https://github.com/makerdao/multicall) smart contract to aggregate function calls and execute them in batches.\n\nRun:\n\n```bash\nnode etherplex\n```\n\nSample results:\n\n```json\n{\n  \"GameCredits\":\"1600000000000000000000 GAME\",\n  \"Swarm Fund\":\"0 SWM\",\n  \"Augur\":\"250684955559177177971383 REP\",\n  \"Tether\":\"52057527540802 USDT\",\n  \"DigixDAO\":\"122062000003 DGD\",\n  \"SingularDTV\":\"1809462 SNGLS\",\n  \"Veros\":\"0 VRS\",\n  \"Golem\":\"83169802320824576633066602 GLM\",\n  \"Circuits of Value\":\"0 COVAL\",\n  \"chrono tech\":\"0 TIME\",\n  \"Melon\":\"0 MLN\",\n  \"WeTrust\":\"0 TRST\",\n  \"iExec RLC\":\"1633118384742405 RLC\",\n  ...\n}\n```\n\n## web3.js BatchRequest\n\n[web3.js](https://github.com/ethereum/web3.js/) is a JavaScript library that makes use of the [generic JSON-RPC methods](https://eth.wiki/json-rpc/API).\n\nThe web3.js `BatchRequest` method aggregates the list of contract function calls and converts them into an array of JSON-RPC calls before sending it to the Ethereum node in one XMLHttpRequest.\n\nRun:\n\n```bash\nnode batch\n```\n\nSample results:\n\n```json\n{\n  \"GameCredits\":\"1600000000000000000000 GAME\",\n  \"Swarm Fund\":\"0 SWM\",\n  \"Augur\":\"250684955559177177971383 REP\",\n  \"Tether\":\"52057527540802 USDT\",\n  \"DigixDAO\":\"122062000003 DGD\",\n  \"SingularDTV\":\"1809462 SNGLS\",\n  \"Veros\":\"0 VRS\",\n  \"Golem\":\"83169802320824576633066602 GLM\",\n  \"Circuits of Value\":\"0 COVAL\",\n  \"chrono tech\":\"0 TIME\",\n  \"Melon\":\"0 MLN\",\n  \"WeTrust\":\"0 TRST\",\n  \"iExec RLC\":\"1633118384742405 RLC\",\n  ...\n}\n```\n\n## Prerequisites\n\n* Node.js: ^16.17.0— [install Node](https://nodejs.org/en/download/)\n* A node RPC endpoint.\n\nDeploy a node with Chainstack:\n\n1. [Sign up with Chainstack](https://console.chainstack.com/user/account/create).  \n1. [Deploy a node](https://docs.chainstack.com/platform/join-a-public-network).  \n1. [View node access and credentials](https://docs.chainstack.com/platform/view-node-access-and-credentials).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainstacklabs%2Fethereum-token-balances-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchainstacklabs%2Fethereum-token-balances-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchainstacklabs%2Fethereum-token-balances-javascript/lists"}