web3-multicall3
v0.2.1
Published
Type-safe typescript wrapper for multicall3
Downloads
45
Maintainers
Readme
Multicall3
is a library for batching contract calls.
Web3-multicall3
is a type-safe multicall3 contract
wrapper
Installation
yarn add web3-multicall3
Usage
const multicall = new Web3Multicall3({
web3: web3Instance, // Web3 v4.*
address: '0xcA11bde05977b3631167028862bE2a173976CA11', // constant address
});
const [someFunctionResponse] = await multicall.aggregate3([
createContractlCall(
contract, // some contract
'someFunctionName', // function name, types are automatically obtained from contract
[arg1, arg2] // someFunction parameters, types validated by web3
)
]);
createContractCall
A utility that provides type support for proper use of web3 contract
Demo
Parameters
- contract - web3.eth.contract
- fnName - function name (obtained from provided contract)
- args - arguments of selected function (types are validated)
Examples
USDC example
- fetching USDC contract owner and balance of zero addressUSDC example (plugin)
- Web3Multicall3Pluge usage
Tests
- Only very base tests are implemented