{"id":23536364,"url":"https://github.com/developerfred/web3-batch-call","last_synced_at":"2026-01-24T21:14:41.812Z","repository":{"id":107465294,"uuid":"315289573","full_name":"developerfred/web3-batch-call","owner":"developerfred","description":null,"archived":false,"fork":false,"pushed_at":"2020-11-23T10:09:14.000Z","size":45,"stargazers_count":4,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T02:19:38.035Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/developerfred.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-11-23T11:11:56.000Z","updated_at":"2022-01-13T05:42:28.000Z","dependencies_parsed_at":"2023-06-11T06:15:10.070Z","dependency_job_id":null,"html_url":"https://github.com/developerfred/web3-batch-call","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fweb3-batch-call","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fweb3-batch-call/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fweb3-batch-call/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developerfred%2Fweb3-batch-call/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developerfred","download_url":"https://codeload.github.com/developerfred/web3-batch-call/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239248396,"owners_count":19607012,"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-12-26T02:19:45.080Z","updated_at":"2025-11-01T02:30:25.498Z","avatar_url":"https://github.com/developerfred.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# web3-batch-call\n\nweb3-batch-call is a tool for querying large amounts of contract data in one json-rpc call.\n\n## Interact\n\nhttps://batchcall.finance\n\n## Features\n\n- Call out to many different contracts in a single batched request\n- Call a large number of methods on various contracts\n- Supply custom arguments to methods\n- Automatically fetch and populate state for viewable no-input methods\n- Supply your own ABIs or automatically fetch and cache ABIs\n- Supports custom contract namespaces\n- Supports historical blocks\n- Isomorphic (works on node and in the browser)\n\n## Use Cases\n\n- Read the complete state of all vaults/staking pools for a protocol as well as user balances\n- Track bulk contract state changes when a contract is touched within a block (give drizzle superpowers)\n- Support real-time contract state tracking cloud infrastructure\n  - Users can subscribe to updates from specific contracts with their own custom arguments (delivered via pub-sub/websocket)\n- Find all uniswap token pairs\n  - Batch read uniswap token factory to obtain pair addresses\n- Find all uniswap token prices\n  - Pass an array of uniswap token addresses with price arguments\n- Contract analytics tooling\n\n## Request Schema\n\n```\n/**\n * Array of contract request configurations\n */\n[\n  {\n    namespace, // Specify a namespace to identify this configuration. Namespace will be used to group contract results\n    addresses, // Specify a list of addresses to iterate through for this contract config\n    abi, // Specify an ABI to use for all addresses in this contract config. If no ABI is specified a unqiue ABI will be fetched and cached for every address. Specifying an ABI is recommended because fetching ABIs via etherscan is time consuming\n    allMethods, // Specify true/flase. If true the contract ABI will be used to fetch state for all viewable methods with no inputs\n    methods: [\n      // Array of methods with custom arguments\n      {\n        name, // method name\n        args, // array of method arguments\n      },\n    ],\n  },\n];\n```\n\n## Installation\n\n```\nnpm install --save web3-batch-call\n```\n\n## Configuration\n\n```\nimport BatchCall from \"web3-batch-call\";\n\nconst provider = \"https://mainnet.infura.io/v3/\u003cyour_infura_api_key\u003e\";\nconst etherscanApiKey = \"\u003cyour_etherscan_api_key\u003e\"\n\nconst options = {\n  provider,\n  etherscan: {\n    apiKey: etherscanApiKey,\n    delayTime: 300, // delay time between etherscan ABI reqests. default is 300 ms\n  },\n}\n\nconst batchCall = new BatchCall(options);\nconst contracts = yourContractsArray\nconst result = await batchCall.execute(contracts, blockNumber);\n\nconsole.log(result);\n```\n\n### Example Request\n\n```\nimport BatchCall from \"web3-batch-call\";\n\nconst contracts = [\n  {\n    namespace: \"vaults\",\n    addresses: [\n      \"0x5dbcF33D8c2E976c6b560249878e6F1491Bca25c\",\n      \"0x29E240CFD7946BA20895a7a02eDb25C210f9f324\",\n    ],\n    allMethods: true,\n    methods: [\n      {\n        name: \"balanceOf\",\n        args: [\"0x1A91C0Df156A5F38aEC0813d055aA0184Fc47826\"],\n      },\n      {\n        name: \"balanceOf\",\n        args: [\"0xF98304d7FB1EE427A8a45B2040677cE57eE454dA\"],\n      },\n    ],\n  },\n  {\n    namespace: \"stakingPools\",\n    addresses: [\"0xBa37B002AbaFDd8E89a1995dA52740bbC013D992\"],\n    allMethods: false,\n    methods: [\n      {\n        name: \"balanceOf\",\n        args: [\"0x29E240CFD7946BA20895a7a02eDb25C210f9f324\"],\n      },\n    ],\n  },\n];\n\nconst provider = \"https://mainnet.infura.io/v3/\u003cyour_infura_api_key\u003e\";\nconst etherscanApiKey = \"\u003cyour_etherscan_api_key\u003e\";\nconst batchCall = new BatchCall({\n  provider,\n  etherscan: {\n    apiKey: etherscanApiKey,\n    delay: 300,\n  },\n});\n\nconst result = await batchCall.execute(contracts);\nconsole.log(result);\n```\n\n### Example Response\n\n```\n{\n  vaults: [\n    {\n      address: '0x5dbcF33D8c2E976c6b560249878e6F1491Bca25c',\n      balanceOf: [\n        {\n          value: '163407599086590',\n          input: '0x70a082310000000000000000000000001a91c0df156a5f38aec0813d055aa0184fc47826',\n          args: [ '0x1A91C0Df156A5F38aEC0813d055aA0184Fc47826' ]\n        },\n        {\n          value: '0',\n          input: '0x70a08231000000000000000000000000f98304d7fb1ee427a8a45b2040677ce57ee454da',\n          args: [ '0xF98304d7FB1EE427A8a45B2040677cE57eE454dA' ]\n        }\n      ],\n      available: [ { value: '175106794577135070165115' } ],\n      balance: [ { value: '69152742956129694188230438' } ],\n      controller: [ { value: '0x9E65Ad11b299CA0Abefc2799dDB6314Ef2d91080' } ],\n      decimals: [ { value: '18' } ],\n      getPricePerFullShare: [ { value: '1115942680749254819' } ],\n      governance: [ { value: '0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52' } ],\n      max: [ { value: '10000' } ],\n      min: [ { value: '10000' } ],\n      name: [ { value: 'yearn Curve.fi yDAI/yUSDC/yUSDT/yTUSD' } ],\n      symbol: [ { value: 'yyDAI+yUSDC+yUSDT+yTUSD' } ],\n      token: [ { value: '0xdF5e0e81Dff6FAF3A7e52BA697820c5e32D806A8' } ],\n      totalSupply: [ { value: '61968006196966914927951406' } ]\n    },\n    {\n      address: '0x29E240CFD7946BA20895a7a02eDb25C210f9f324',\n      balanceOf: [\n        {\n          value: '0',\n          input: '0x70a082310000000000000000000000001a91c0df156a5f38aec0813d055aa0184fc47826',\n          args: [ '0x1A91C0Df156A5F38aEC0813d055aA0184Fc47826' ]\n        },\n        {\n          value: '344733454224',\n          input: '0x70a08231000000000000000000000000f98304d7fb1ee427a8a45b2040677ce57ee454da',\n          args: [ '0xF98304d7FB1EE427A8a45B2040677cE57eE454dA' ]\n        }\n      ],\n      aave: [ { value: '0x24a42fD28C976A61Df5D00D0599C34c4f90748c8' } ],\n      availableToBorrowETH: [ { value: '12871798970841184666681' } ],\n      availableToBorrowReserve: [ { value: '6918769017550' } ],\n      balance: [ { value: '2991115423000586249520147' } ],\n      controller: [ { value: '0x2be5D998C95DE70D9A38b3d78e49751F10F9E88b' } ],\n      credit: [ { value: '6571575672124' } ],\n      debt: [ { value: '6568313166454' } ],\n      decimals: [ { value: '18' } ],\n      getAave: [ { value: '0x398eC7346DcD622eDc5ae82352F02bE94C62d119' } ],\n      getAaveCore: [ { value: '0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3' } ],\n      getAaveOracle: [ { value: '0x76B47460d7F7c5222cFb6b6A75615ab10895DDe4' } ],\n      getPricePerFullShare: [ { value: '1050253924653889449' } ],\n      getReservePrice: [ { value: '1860417501753607' } ],\n      getUnderlyingPrice: [ { value: '27108074719526996' } ],\n      governance: [ { value: '0x2D407dDb06311396fE14D4b49da5F0471447d45C' } ],\n      healthFactor: [ { value: '2' } ],\n      insurance: [ { value: '6823725788804860163571' } ],\n      locked: [ { value: '1000496703733107980' } ],\n      ltv: [ { value: '65' } ],\n      max: [ { value: '100' } ],\n      maxSafeETH: [\n        {\n          value: Result {\n            '0': '26412214466011430693228',\n            '1': '12219804771869674491885',\n            '2': '40604624160153186894572',\n            maxBorrowsETH: '26412214466011430693228',\n            totalBorrowsETH: '12219804771869674491885',\n            availableBorrowsETH: '40604624160153186894572'\n          }\n        }\n      ],\n      name: [ { value: 'yearn Aave Interest bearing LINK' } ],\n      over: [ { value: '0' } ],\n      reserve: [ { value: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' } ],\n      shouldBorrow: [ { value: true } ],\n      shouldRebalance: [ { value: false } ],\n      symbol: [ { value: 'yaLINK' } ],\n      token: [ { value: '0xA64BD6C70Cb9051F6A9ba1F163Fdc07E0DfB5F84' } ],\n      totalSupply: [ { value: '2847992616629646531247502' } ],\n      underlying: [ { value: '0x514910771AF9Ca656af840dff83E8264EcF986CA' } ]\n    }\n  ],\n  stakingPools: [\n    {\n      address: '0xBa37B002AbaFDd8E89a1995dA52740bbC013D992',\n      balanceOf: [\n        {\n          value: '739758310196',\n          input: '0x70a082310000000000000000000000001a91c0df156a5f38aec0813d055aa0184fc47826',\n          args: [ '0x1A91C0Df156A5F38aEC0813d055aA0184Fc47826' ]\n        }\n      ]\n    }\n  ]\n}\n```\n\n## How it works\n\nUnder the hood the web3 [BatchRequest](https://web3js.readthedocs.io/en/v1.3.0/include_package-core.html?highlight=batchrequest#batchrequest) class is utilized.\n\n```javascript=\nvar contract = new web3.eth.Contract(abi, address);\n\nvar batch = new web3.BatchRequest();\nbatch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback));\nbatch.add(contract.methods.balance(address).call.request({from: '0x0000000000000000000000000000000000000000'}, callback2));\nbatch.execute();\n```\n\n`web3-batch-call` essentially takes a user-generated contract configuration file and programatically builds and executes a batched json-rpc request using the provided configuration. The results are grouped by namespace and formatted into a JSON object that can be consumed by your application.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperfred%2Fweb3-batch-call","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloperfred%2Fweb3-batch-call","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperfred%2Fweb3-batch-call/lists"}