{"id":13620870,"url":"https://github.com/wbobeirne/eth-balance-checker","last_synced_at":"2025-04-13T02:24:59.485Z","repository":{"id":37752138,"uuid":"151916500","full_name":"wbobeirne/eth-balance-checker","owner":"wbobeirne","description":"Solidity contract to batch balance checks in one call","archived":false,"fork":false,"pushed_at":"2024-03-12T19:01:23.000Z","size":1231,"stargazers_count":257,"open_issues_count":18,"forks_count":83,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-04T04:12:25.729Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/wbobeirne.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":"2018-10-07T07:26:59.000Z","updated_at":"2025-03-20T15:16:55.000Z","dependencies_parsed_at":"2024-06-18T17:09:09.897Z","dependency_job_id":"7d51ff65-f5a4-4b9f-8143-718bbde56f24","html_url":"https://github.com/wbobeirne/eth-balance-checker","commit_stats":{"total_commits":24,"total_committers":9,"mean_commits":"2.6666666666666665","dds":0.5833333333333333,"last_synced_commit":"028440a97bd3c39a8620b3aae287b4b01db3144b"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbobeirne%2Feth-balance-checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbobeirne%2Feth-balance-checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbobeirne%2Feth-balance-checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbobeirne%2Feth-balance-checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wbobeirne","download_url":"https://codeload.github.com/wbobeirne/eth-balance-checker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248655031,"owners_count":21140417,"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":[],"created_at":"2024-08-01T21:01:00.203Z","updated_at":"2025-04-13T02:24:59.457Z","avatar_url":"https://github.com/wbobeirne.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.imgur.com/2ZBxjyu.png\" width=\"340\" /\u003e\n  \u003ch1\u003eEthereum Balance Checker\u003c/h1\u003e\n\u003c/p\u003e\n\nA smart contract and library pair that allows you to check for multiple ERC20\nand Ether balances across multiple addresses in a single RPC call.\n\n## Demo\n\nYou can find a demo over here: https://wbobeirne.github.io/eth-balance-checker-demo\n\nThe source for that demo is available here: https://github.com/wbobeirne/eth-balance-checker-demo\n\n## NPM Package\n\n```\nnpm install --save eth-balance-checker\n# OR\nyarn add eth-balance-checker\n```\n\n### Contract\n\nThe main contract is in `contracts/BalanceChecker.sol`. Its associated ABI is in `abis/BalanceChecker.abi.json`. Both of these are included in the NPM package if you want to compile them yourself, or extend them with another\ncontract.\n\n#### Deployed Addresses\n\n- mainnet: `0xb1f8e55c7f64d203c1400b9d8555d050f94adf39`\n- ropsten: `0x8D9708f3F514206486D7E988533f770a16d074a7`\n- rinkeby: `0x3183B673f4816C94BeF53958BaF93C671B7F8Cf2`\n- kovan: `0x55ABBa8d669D60A10c104CC493ec5ef389EC92bb`\n- goerli: `0x9788C4E93f9002a7ad8e72633b11E8d1ecd51f9b`\n- binance smart chain mainnet: `0x2352c63A83f9Fd126af8676146721Fa00924d7e4`\n- binance smart chain testnet: `0x2352c63A83f9Fd126af8676146721Fa00924d7e4`\n- polygon: `0x2352c63A83f9Fd126af8676146721Fa00924d7e4`\n- mumbai: `0x2352c63A83f9Fd126af8676146721Fa00924d7e4`\n- Optimism: `0xB1c568e9C3E6bdaf755A60c7418C269eb11524FC`\n- Optimism Kovan: `0xB1c568e9C3E6bdaf755A60c7418C269eb11524FC`\n- arbitrum: `0x151E24A486D7258dd7C33Fb67E4bB01919B7B32c`\n- avalanche: `0xD023D153a0DFa485130ECFdE2FAA7e612EF94818` and `0xE0baF851F839874141bB73327f9C606147a52358`\n- fantom: `0x07f697424ABe762bB808c109860c04eA488ff92B` and `0xfC701A6b65e1BcF59fb3BDbbe5cb41f35FC7E009`\n- ether-classic: `0xfC701A6b65e1BcF59fb3BDbbe5cb41f35FC7E009`\n- Tron: `TN8RtFXeQZyFHGmH1iiSRm5r4CRz1yWkCf` --\u003e Yes, it also works in Tron! Use hex addresses format to interact with it (41...).\n\n### Library\n\nThere are separate libraries for [web3.js](https://github.com/ethereum/web3.js/)\nand [ethers.js](https://github.com/ethers-io/ethers.js/), both with identical\nAPIs. Just import the functions from either `eth-balance-checker/lib/web3` or\n`eth-balance-checker/lib/ethers`. For all functions, pass `\"0x0\"` as the \"token\"\naddress to get the ether balance of an address.\n\nAll functions also take in an optional 4th options parameter, those options are as follows:\n\n```typescript\ninterface Options {\n  // Choose a custom contract address. Must be provided to run the\n  // code on non-mainnet network.\n  contractAddress?: string;\n}\n```\n\n#### getAddressBalances\n\n##### Parameters\n* `provider: Web3 | Ethers.Provider` - The provider to use for the contract call.\n* `address: string` - The address to lookup balances for\n* `tokens: string[]` - Array of token contract addresses. Only supports ERC20 tokens.\n* `options?: Options` - Options for the contract, see above for options.\n\n##### Returns\n```js\nPromise\u003c{\n  // Ether balance\n  \"0x0\": \"100\",\n  // Token balances\n  \"0x123...\": \"500\",\n  \"0x456...\": \"100000\",\n  ...\n}\u003e\n```\n\n##### Example\n```ts\nimport Web3 from 'web3';\nimport { getAddressBalances } from 'eth-balance-checker/lib/web3';\n\nconst web3 = new Web3(...);\nconst address = '0x123...';\nconst tokens = ['0x0', '0x456...'];\ngetAddressBalances(web3, address, tokens).then(balances =\u003e {\n  console.log(balances); // { \"0x0\": \"100\", \"0x456...\": \"200\" }\n});\n```\n\n#### getAddressesBalances\n\n##### Parameters\n* `provider: Web3 | Ethers.Provider` - The provider to use for the contract call.\n* `addresses: string[]` - Array of addresses to lookup balances for.\n* `tokens: string[]` - Array of token contract addresses. Only supports ERC20 tokens.\n* `options?: Options` - Options for the contract, see above for options.\n\n##### Returns\n```js\nPromise\u003c{\n  // Address as the key\n  \"0x123...\": {\n    // Ether balance\n    \"0x0\": \"100\",\n    // Token balances\n    \"0x456...\": \"500\",\n    \"0x789...\": \"10000\",\n    ...\n  },\n  ...\n}\u003e\n```\n\n##### Example\n```ts\nimport * as Ethers from 'ethers';\nimport { getAddressesBalances } from 'eth-balance-checker/lib/ethers';\n\nconst ethers = Ethers.getDefaultProvider();\nconst addresses = ['0x123...', '0x456...'];\nconst tokens = ['0x0', '0x789...'];\ngetAddressesBalances(ethers, addresses, tokens).then(balances =\u003e {\n  console.log(balances); // { \"0x123...\": { \"0x0\": \"100\", ... }, ... }\n});\n```\n\n## Development\n\n### Setup\n\nRequires node 8+. Just install packages, then use commands as needed:\n\n```bash\nnpm install\n# OR\nyarn\n```\n\n### Commands\n\n* `build:contract` - Runs `truffle compile` on the contract, and extracts ABI.\n* `build:lib` - Runs `tsc` and outputs js and typedefs to `lib/`\n* `build` - Runs `build:contract` then `build:lib`\n* `test:contract` - Runs `truffle test`\n* `test:lib` - No tests implemented yet\n* `test` - Runs `tst:contract` and `test:lib`\n\n## Credits\n\n* Thanks to [@henrynguyen5](https://github.com/henrynguyen5) for adapting\n[@DeltaBalances](https://github.com/DeltaBalances)' smart contract for this\n* This library came out of EthSanFrancisco from the\n[Safu Chrome Extension](https://github.com/grant-project/safu-extension) project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbobeirne%2Feth-balance-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwbobeirne%2Feth-balance-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbobeirne%2Feth-balance-checker/lists"}