{"_id":"@apeboard/multicall","_rev":"4-047461b477008133f20c52eff0b76e46","name":"@apeboard/multicall","dist-tags":{"latest":"0.25.2"},"versions":{"0.25.1":{"name":"@apeboard/multicall","version":"0.25.1","description":"multicall sub-package for Sequence","repository":{"type":"git","url":"https://github.com/0xsequence/sequence.js/tree/master/packages/multicall"},"source":"src/index.ts","main":"dist/0xsequence-multicall.cjs.js","module":"dist/0xsequence-multicall.esm.js","author":{"name":"Horizon Blockchain Games"},"license":"Apache-2.0","scripts":{"test":"TS_NODE_PROJECT=../../tsconfig.test.json mocha -r ts-node/register --timeout 60000 tests/**/*.spec.ts","typecheck":"tsc --noEmit"},"dependencies":{"@0xsequence/abi":"^0.25.1","@0xsequence/network":"^0.25.1","@0xsequence/utils":"^0.25.1","@ethersproject/providers":"^5.0.24","ethers":"^5.0.32"},"devDependencies":{"@0xsequence/wallet-contracts":"1.9.1","@types/web3-provider-engine":"^14.0.0","eth-json-rpc-middleware":"^7.0.1","json-rpc-engine":"^6.1.0","web3":"^1.3.5","web3-provider-engine":"^16.0.1"},"_id":"@apeboard/multicall@0.25.1","_nodeVersion":"14.9.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-uCh4+lzTkgeKdQFsTh80R3ceBwzR7znJZqVe4mF0X/Tgrh88uDSPTnrFXASlUjXM2J3qU1B7F6tIf9eimWy8YA==","shasum":"a107258c8c3b55c265c2ee38bc405aad434bdba1","tarball":"https://registry.npmjs.org/@apeboard/multicall/-/multicall-0.25.1.tgz","fileCount":25,"unpackedSize":85829,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg8baeCRA9TVsSAnZWagAA3kEP/06/hyvkX/HMmrDUNLnO\nCQ1+765rwTPEdUyyEZhsdRUcONmiUz6SWWMpxThFCsceWf+yy0xoNdKj9xpS\nPwF9JnnBcEkS/k9eMztlBLClYG0gOd+B9Dh8olQaLm7f/9jyxWcDmqMHlUZQ\njUPUtvtX/F8896HCkKv1bldbRxQ9euJRj1QJt8cOHR8SLlVNfZbCEnWd94Hq\nfHrVVKySZtz1TMH8p6egN4VE/nweB06SLd9RfONRPIfpR6B+6WjT/qFIYoD6\nbPR4ka9QM8qFuCfPHQj31tGbX8nXMZxcShhLFDTbrg684FDZIUYTFpzmBCuQ\nraJhZZN9P3A+pdqbG9wcVa3UsyAAdBRnmvZAfjka+59RkOoUjn1dIGFERaak\nsavFLR3gChQkSdk1MHaVwpZOUiNgfDXJMV0vpTAJWta0x+h/5RKrkBNLHH7c\nZR0e0ce87r/E8olrVgoxK9NFpkxshio1jyNcF9tZI3ACQSUapf3pNo9BRDwg\nkUWVuuSCBGg9HwxPkEVy+OgKGxiaa6VZqxrJilJAceoVeVJiMkQqT9fjOiuW\n6GxMz+oNYY0CcnU1+8dal0Yp6gA9EVLra+9y3Gy46ATDWMMPkSYDr1U34Veg\n8vgEqGcN0Y42LPEKgWpOjV01QfnxTfr3BPW6rY5jG1C11rv4PiHQ2PTHRdQE\nq8E1\r\n=LPFG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICaJUuXa74tgDrkUhamYQSxNGAPohaI9TyGVZ89z5P31AiAJY4VgSkfDq6UzMLPCOJ5SzjAMGYfX1q0zT3cPiK8LBw=="}]},"_npmUser":{"name":"witchayut","email":"witchayut.jong@gmail.com"},"directories":{},"maintainers":[{"name":"witchayut","email":"witchayut.jong@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multicall_0.25.1_1626453661865_0.41841213984538395"},"_hasShrinkwrap":false},"0.25.2":{"name":"@apeboard/multicall","version":"0.25.2","description":"multicall sub-package for Sequence","repository":{"type":"git","url":"https://github.com/0xsequence/sequence.js/tree/master/packages/multicall"},"source":"src/index.ts","main":"dist/apeboard-multicall.cjs.js","module":"dist/apeboard-multicall.esm.js","author":{"name":"Horizon Blockchain Games"},"license":"Apache-2.0","scripts":{"test":"TS_NODE_PROJECT=../../tsconfig.test.json mocha -r ts-node/register --timeout 60000 tests/**/*.spec.ts","typecheck":"tsc --noEmit"},"dependencies":{"@0xsequence/abi":"^0.25.1","@0xsequence/network":"^0.25.1","@0xsequence/utils":"^0.25.1","@ethersproject/providers":"^5.0.24","ethers":"^5.0.32"},"devDependencies":{"@0xsequence/wallet-contracts":"1.9.1","@types/web3-provider-engine":"^14.0.0","eth-json-rpc-middleware":"^7.0.1","json-rpc-engine":"^6.1.0","web3":"^1.3.5","web3-provider-engine":"^16.0.1"},"_id":"@apeboard/multicall@0.25.2","_nodeVersion":"14.9.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-8cmZJDOaYPfb0FQhOFEXtUGzrMZ5cnBFyIPwd5Olmpo7WSdmbDMYWCLPkPRxMusWXMSsZEMQEi3D0RqdlJEYPw==","shasum":"d2773fbc22b1cbe38e313ff488c43407d5ef1ce8","tarball":"https://registry.npmjs.org/@apeboard/multicall/-/multicall-0.25.2.tgz","fileCount":25,"unpackedSize":86376,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh11rVCRA9TVsSAnZWagAA89IP/3awK4YtMlwlVUYFYecj\nQhH6JHTm+YOFKIOG2tw3GynpQBcfAkZ+l70tuwpYv0rZYjsYmX6hgafjJdkQ\nvSs73MJsYYO7rJJXkaglKaoJFfz4d4tGoeBVURNzW+JAoT4CLeCe1gfDlqJq\nEVdbtUmLHqIKc6L6N8bMwTpbxZAhurOb6uyA6STxWKawjHIZzskZHVxaSlel\n1Y7SJF34ZB4D1ClFrkoEFU0r10dwSKYZ7YpSeqh6TFPWBBg0KKewXlIrwfX5\nLnPEpGZMB1R2YTkHZG6snBRQZx/rqSlQkzs0pbHhcuyZ4cTaPu5ZoGgAbFL6\ncZ1G7KPi9z6q0qw3zMG7KLMhKq5BWE9S8AYrDJh/8rZ/PRl5Or9ZfNNgPOzl\nvflVvlw7hck2dxVkSE98Spu29B0gsgkubqbHG81SXDKtYOfmdkt42UjOG7tf\n/NP78lhZtVh4yMD69hz+KMgVxmGzCIRF+lIUI4gxkx5YEUGJaCy56G2ztkjD\nHNlcpQhAKHR8m2XTLZUfP7FPUwJeA7csrXmt9J3w8SerxAYSloLH7aMP62N1\nU84ZPJ5HXFnJrrlyRNdYuGBQyNUxLJq0xW6zXn4KHD8QtBm1AtmJhMZRPKQA\nVOc2R7/SrP/9kua9p0yIi5ojnVSnEAC/cFrT1Q/rFOiAtchNzeaDFvr9Cub4\n332I\r\n=rFH1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGus0qCAvJSej2ZkRkUdL55IgtZf3fRShWWfpf5Tx0S7AiAtqVUXOuNrXt95lPi2yM6kfl+wZFLOlrWx8K5B2wm8oQ=="}]},"_npmUser":{"name":"witchayut","email":"witchayut.jong@gmail.com"},"directories":{},"maintainers":[{"name":"witchayut","email":"witchayut.jong@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/multicall_0.25.2_1626454820441_0.5279853609084679"},"_hasShrinkwrap":false}},"time":{"created":"2021-07-16T16:41:01.474Z","0.25.1":"2021-07-16T16:41:02.010Z","modified":"2022-04-04T14:32:40.981Z","0.25.2":"2021-07-16T17:00:20.588Z"},"maintainers":[{"email":"jackykongpon@gmail.com","name":"kykungz"},{"email":"witchayut.jong@gmail.com","name":"witchayut"}],"description":"multicall sub-package for Sequence","repository":{"type":"git","url":"https://github.com/0xsequence/sequence.js/tree/master/packages/multicall"},"author":{"name":"Horizon Blockchain Games"},"license":"Apache-2.0","readme":"@0xsequence/multicall\n=====================\n\nAn Ethereum provider wrapper that aggregates multiple operations in one, reducing the network load on clients and servers. The project aims to be plug-and-play with existing ether.js integrations.\n\nFor more info see [0xsequence project page](https://github.com/0xsequence/sequence.js).\n\nInspired by MakerDAO [Multicall.js](https://github.com/makerdao/multicall.js).\n\n## Installation\n\n`yarn add @0xsequence/multicall`\n\nor\n\n`npm install --save @0xsequence/multicall`\n\n## Usage\n\nSequence Multicall works by implementing `ethers.Provider` and wrapping an existing `ethers.Provider`; this wrapped provider can transparently aggregate supported JSON-RPC calls.\n\n```ts\nimport { providers } from '@0xsequence/multicall'\nimport { providers as ethersProviders } from 'ethers'\n\n// MulticallProvider can wrap and extend with multicall functionality\n// any ethers.js provider, it's not limited to JsonRpcProvider\nconst provider = new providers.MulticallProvider(new ethersProviders.JsonRpcProvider(\"https://cloudflare-eth.com/\"))\n```\n\n### Making aggregated calls\n\nMulticall leverages RPC calls' asynchronous nature to perform the aggregation; it implements a buffer with a configurable 50ms delay and aggregates all operations received within that window.\n\nExplicit usage of the functionality can be forced by making multiple calls using `Promise.all`.\n\n```ts\n// Both requests are aggregated into a single RPC call\nconst [balance, supply] = await Promise.all([\n  provider.getBalance(\"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\"),\n  dai.totalSupply()\n])\n```\n\nMethods can also be aggregated without using `Promise.all`, as long as there are no `await` in between calls.\n\n```ts\n// DON'T\nconst balance = await provider.getBalance(\"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\")\nconst supply = await dai.totalSupply()\n\n// DO\nconst balancePromise = provider.getBalance(\"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\")\nconst supplyPromise = dai.totalSupply()\n\nconst balance = await balancePromise\nconst supply = await supplyPromise\n```\n\n## Using the provider\n\nThe `MulticallProvider` instance can be used in any context where an ethers.Provider is expected, including contract interfaces, middlewares, or libraries; all calls to the same provider are candidates for aggregation.\n\n```ts\n// Uses a single JSON-RPC call\n\nconst abi = [\n    \"function balanceOf(address owner) view returns (uint256)\",\n    \"function totalSupply() view returns (uint256)\",\n    \"function symbol() view returns (string)\",\n]\n\nconst uni = new ethers.Contract(\"0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984\", abi, provider)\nconst dai = new ethers.Contract(\"0x6B175474E89094C44Da98b954EedeAC495271d0F\", abi, provider)\n\nconst uniTotalSupplyPromise = uni.totalSupply()\n\nconst [totalSupply, balance, daiSymbol, uniSymbol] = await Promise.all([\n  dai.totalSupply(),\n  dai.balanceOf(\"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\"),\n  dai.symbol(),\n  uni.symbol()\n])\n\nconst uniTotalSupply = await uniTotalSupplyPromise\n```\n\n### Supported methods\n\nThe following JSON-RPC methods are supported for call aggregation:\n\n| Method          | Supported | Implemented | Notes                                                                |\n|-----------------|-----------|-------------|----------------------------------------------------------------------|\n| eth_call        | Yes       | Yes         | Requests containing `from`, `gasPrice` or `value` aren't aggregated. |\n| eth_getBalance  | Yes       | Yes         |                                                                      |\n| eth_getCode     | Yes       | Yes         |                                                                      |\n| eth_blockNumber | Yes       | No          |                                                                      |\n\nAll other RPC methods that are part of the standard are forwarded to the parent provider without any modifications.\n\n> ⚠️ Using mixed blocktags will make some calls skip aggregation.\n\n### Error handling\n\nThe multicall wrapper is designed to work with any exiting ether.js integration transparently; this includes error handling for cases when multicall fails, is wrongly configured, or the contract does not support it.\n\nJSON-RPC Calls are forwarded to the parent provider on any of the following cases:\n\n- Multicall contract is not deployed on the given network\n- Individual call fails (only failed calls are forwarded)\n- Batch call fails (all calls are forwarded)\n- Invalid RPC Call (invalid address, etc.)\n- Mixed blocktags within a batch\n- Unsupported special parameters (see supported methods)\n- Unsupported method\n\n## Configuration\n\nThe MulticallProvider comes with a pre-defined configuration; it's ready to work out-of-the-box on the networks: Mainnet, Ropsten, Kovan, Rinkeby, Görli, and Matic (Mainnet).\n\n```ts\nDEFAULT_CONF = {\n  batchSize: 50,\n  timeWindow: 50, // ms\n  contract: \"0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80\"\n}\n```\n| Parameter  | Required | Description                                                                                                                                  |\n|------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| batchSize  | Yes      | Defines the maximum number of calls to batch into a single JSON-RPC call.                                                                    |\n| timeWindow | Yes      | Defines the time each call is held on buffer waiting for subsequent calls before aggregation, use 0 for \"next js tick\".                      |\n| contract   | Yes      | Instance of MultiCallUtils contract, see: https://github.com/0xsequence/wallet-contracts/blob/master/src/contracts/modules/utils/MultiCallUtils.sol. |\n\n### Supported networks\n\nThe utility contract is `0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80`, it has been deployed using an [Universal Deployer](https://gist.github.com/Agusx1211/de05dabf918d448d315aa018e2572031) and it uses the same address on all networks. It can be used on any of these chains without configuration changes.\n\n| Network                | Address                                    | Deployed |\n|------------------------|--------------------------------------------|----------|\n| Mainnet                | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n| Ropsten                | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n| Rinkeby                | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n| Kovan                  | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n| Görli                  | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n| Matic                  | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n| Mumbai (Matic testnet) | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n| Arbitrum testnet       | 0xCa731e0f33Afbcfa9363d6F7449d1f5447d10C80 | Yes      |\n\nIt can be deployed on any network that supports the `CREATE2` opcode.\n","readmeFilename":"README.md"}