{"_id":"@bthn/eth-balance-checker","_rev":"1-17af922df8bbdcfbe389da62f8808cd1","name":"@bthn/eth-balance-checker","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.2":{"name":"@bthn/eth-balance-checker","version":"0.1.2","description":"Ethereum smart contract and library for efficient ERC20 and Ether balance checks.","main":"lib/index.js","types":"lib/index.d.ts","sideEffects":false,"author":{"name":"Will O'Beirne","email":"wbobeirne@gmail.com"},"contributors":[{"name":"Henry Nguyen"}],"license":"MIT","homepage":"https://github.com/wbobeirne/eth-balance-checker","bugs":{"url":"https://github.com/wbobeirne/eth-balance-checker/issues"},"repository":{"type":"git","url":"git+https://github.com/wbobeirne/eth-balance-checker.git"},"keywords":["ethereum","ether","erc20","balance","solidity"],"scripts":{"build":"npm run build:contract && npm run build:lib","build:lib":"tsc","build:contract":"truffle compile && node scripts/export-abi","test":"npm run test:lib && npm run test:contract","test:lib":"echo 'no tests yet'","test:contract":"truffle test","prepublish":"npm run build"},"devDependencies":{"@truffle/hdwallet-provider":"^2.0.4","chai":"^4.3.6","dotenv":"^16.0.0","eth-gas-reporter":"^0.2.24","ethers":"^5.6.0","openzeppelin-solidity":"^1.12.0","truffle":"^5.5.4","typescript":"^4.6.2","web3":"^1.7.1"},"peerDependencies":{"ethers":"^5.4.0","web3":"^1.4.0"},"gitHead":"8ffb0163deb37807ade88cf1bccdb665fc08a666","_id":"@bthn/eth-balance-checker@0.1.2","_nodeVersion":"17.1.0","_npmVersion":"8.1.2","dist":{"integrity":"sha512-RpbgJF5vPuDRBIsIPekzju6QPcVqU/yZDdQy9XNts4hdsTw+zd5KSUpxmh/4KNKwzM115V/A1IWmNVyU7nHl/w==","shasum":"25d02bcda6a8d57f1b559c6d34932f4b460f0f3a","tarball":"https://registry.npmjs.org/@bthn/eth-balance-checker/-/eth-balance-checker-0.1.2.tgz","fileCount":15,"unpackedSize":23965,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC6hT8TKffcphj7b4HVKQgdYGjat5SmGV9XfzK9EeAf6AIgPkSmwHHf7lZKk6+Jw9C9mdf7lADZOXUuCam7Ixo3Jac="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiTXoaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmomBhAAiZ2RMt6I/XLMIp2NQju8l/OPHFOb1bnoOMJyhmJfGBUh5/Zf\r\n1OG0JcmNVb5riy2yD5HEUofk47Ez3NsHK5FHhtStf6CfhZyUjXTbqjFXo6RF\r\nmMS7XglwNPEufWDJY41xqQW9d4g0Wu/Rk0PMUD+IQxOnIDO7mhdZD1EtIFZM\r\nWb+N9Lskv8OfT/T2RKH2r/3r+3L4blQ17p/tsTpgBhHIIkrqL5AzZhSPCYcj\r\n+jtZvPsZKdDbKGLX4QZ31ROn1W4CHxbMBOhGoz/ATpgH9pSFTY7HzN6tIVPx\r\nAoKhc4XW6ljLH1kEw+4ZMW6cDu6deHPu08wnkBsYdmkJWg3py4NC0SB2WIFP\r\nGQfHOiRvFTpa44RyFWgqKjy7wcaizbmbWW3xN5fWXtBZAq7DF2Bd5MFYAMau\r\nkMR8FbrNEDmASxS9Uq6z2lpIzojcKs1M3/HVPTVmANCXF/y7k82ImlwxzNWr\r\nKOJqOhsdZp5isXBhKbZZ5FTvksHx0UbaEQUxCbl9d0cDMzEu5j3KlPKD1eJK\r\ntCBBczrWEnxFXU6/9SQnK1tuRW8yZdieILGFP+48KFniy3u2Hkja0uvpTofB\r\ngGA0WmhLz2Yx7P6E0u2ytnqdQi0AgPW4+7zmoRZRNrd9//iYK+7xkoXn4CSi\r\neTMR8eSyGZ1ZvdPIhxGPPvKp2UPeA4l29q8=\r\n=S/Lb\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bthn","email":"katircib@gmail.com"},"directories":{},"maintainers":[{"name":"bthn","email":"katircib@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-balance-checker_0.1.2_1649244698425_0.532100823241265"},"_hasShrinkwrap":false},"0.1.3":{"name":"@bthn/eth-balance-checker","version":"0.1.3","description":"Ethereum smart contract and library for efficient ERC20 and Ether balance checks.","main":"lib/index.js","types":"lib/index.d.ts","sideEffects":false,"author":{"name":"Will O'Beirne","email":"wbobeirne@gmail.com"},"contributors":[{"name":"Henry Nguyen"}],"license":"MIT","homepage":"https://github.com/wbobeirne/eth-balance-checker","bugs":{"url":"https://github.com/wbobeirne/eth-balance-checker/issues"},"repository":{"type":"git","url":"git+https://github.com/wbobeirne/eth-balance-checker.git"},"keywords":["ethereum","ether","erc20","balance","solidity"],"scripts":{"build":"npm run build:contract && npm run build:lib","build:lib":"tsc","build:contract":"truffle compile && node scripts/export-abi","test":"npm run test:lib && npm run test:contract","test:lib":"echo 'no tests yet'","test:contract":"truffle test","prepublish":"npm run build"},"devDependencies":{"@truffle/hdwallet-provider":"^2.0.4","chai":"^4.3.6","dotenv":"^16.0.0","eth-gas-reporter":"^0.2.24","ethers":"^5.6.0","openzeppelin-solidity":"^1.12.0","truffle":"^5.5.4","typescript":"^4.6.2","web3":"^1.7.1"},"peerDependencies":{"ethers":"^5.4.0","web3":"^1.4.0"},"gitHead":"8ffb0163deb37807ade88cf1bccdb665fc08a666","_id":"@bthn/eth-balance-checker@0.1.3","_nodeVersion":"17.1.0","_npmVersion":"8.1.2","dist":{"integrity":"sha512-FpiP7zyAfHaoDmSxbaEbYDcB4TvgqvOJNetokEDby4vl/MhZ6WJ0XBvBZHop29bDlioABzPQ4Nhnxd2Bf8qHZQ==","shasum":"ff931af82031f95592378cf8d7ffade5c2afd9d3","tarball":"https://registry.npmjs.org/@bthn/eth-balance-checker/-/eth-balance-checker-0.1.3.tgz","fileCount":24,"unpackedSize":37524,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAtYJeKlkyBaNJmMgFtINOURFnPw9KiWyMd9egAUvny5AiEAtdyT5ECCIizTT4cIeAFd1+h2kD3pqVJFl5LDKKcALSM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiTXrgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrjCQ/9E6RcBiqZj3Gs/4wxaPxFIAXooZKt3A6n2fGfOsTl2BSrRwE6\r\nLwLNT9SeiZpDnXvPU2HC4ahIQHt0VsAq9JWNGOSY2ntVcy74hdPRyLbudq/Q\r\nUp8O9/7eWLsALfOEjE722R8dAwjbtSZ1t9jXNxc39yQpGw6Nsd/SYCq35vlO\r\n799mIPxu87kSMy1JI4tO5UD2vDwm5OnRS+8W+KW8NTU++BDDqS6Nv4KmmkPi\r\nBAkxPLo30ll2SrzFq438WrNuy6BPv6mpmNUx7ZdNoX+YkJfiX9I2xHLZ3LPH\r\ng2X79uFXssJIVe7rHB43+BLTE/aRmqBvemi0tM51jfteKPU9JtLun4BcLVk4\r\neprrDaHuEK50yBJuQgDmopnzmXXaGYT1iGnCFaAwo36BvhSIQ4bqfqCzE7+x\r\nZrVa3/yMbExP5LN//NJYZKyN6DcKAyKD+O/r4/WBLBdLXTwllN6pzzhotP1a\r\ndfm1MAfTpGjmenVpMmECwpDSS9+p/L6CQkHCi42cl97sTDLNg5FbQikh5fxR\r\nVTEJ54/uDNS6r5lqeJuQQRcmuKd1vUtp3l0nUOd+z1f8O4A1Uk43u90Wbr5l\r\n4WVXH3DXF1xsigC9EoYfJHmyORNe6WlXotRmqHxYwS6TSnwNH7GEHu/okR40\r\nYYYV9MpplBuYmlra7HAI69VLMXICZIHzcmo=\r\n=OgWz\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bthn","email":"katircib@gmail.com"},"directories":{},"maintainers":[{"name":"bthn","email":"katircib@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-balance-checker_0.1.3_1649244896100_0.5828808276211928"},"_hasShrinkwrap":false}},"time":{"created":"2022-04-06T11:31:38.369Z","0.1.2":"2022-04-06T11:31:38.592Z","modified":"2022-04-06T11:34:56.400Z","0.1.3":"2022-04-06T11:34:56.340Z"},"maintainers":[{"name":"bthn","email":"katircib@gmail.com"}],"description":"Ethereum smart contract and library for efficient ERC20 and Ether balance checks.","homepage":"https://github.com/wbobeirne/eth-balance-checker","keywords":["ethereum","ether","erc20","balance","solidity"],"repository":{"type":"git","url":"git+https://github.com/wbobeirne/eth-balance-checker.git"},"contributors":[{"name":"Henry Nguyen"}],"author":{"name":"Will O'Beirne","email":"wbobeirne@gmail.com"},"bugs":{"url":"https://github.com/wbobeirne/eth-balance-checker/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <img src=\"https://i.imgur.com/2ZBxjyu.png\" width=\"340\" />\n  <h1>Ethereum Balance Checker</h1>\n</p>\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`\n- fantom: `0x07f697424ABe762bB808c109860c04eA488ff92B`\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<{\n  // Ether balance\n  \"0x0\": \"100\",\n  // Token balances\n  \"0x123...\": \"500\",\n  \"0x456...\": \"100000\",\n  ...\n}>\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 => {\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<{\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}>\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 => {\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","readmeFilename":"README.md"}