Skip to content

A simple multicall contract and library wrapper to aggregate Ethereum calls.

Notifications You must be signed in to change notification settings

ricmoo/multicall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multicall

A multicall contract enables a single eth_call to be used to aggregate multiple constant contract method calls to a variety of addresses.

The ethers Multicall contract is located at multicall.eth and is verified on Etherscan.

JavaScript API

const multicaller = Multicaller(provider);

// The maximum amount of gas to allow each sub-call to consume
multicaller.gasLimtPerCall = 50000;

// The maximum result length to allow each call to return
multicaller.resultLimitPerCall = 1024;

multicaller.queue(address, fragment [ , values ]) => Promise<any>
multicaller.queueResult(address, fragment [ , values ]) => Promise<Result>
multicall.flush() => Promise<number>

Contract API

const ABI = [
  "function execute(uint gasLimit, uint maxResultSize, address[] addrs, bytes[] datas) view returns (uint blockNumber, uint[] statuses, bytes[] results)"
];

const contract = new Contract("multicall.eth", ABI, provider);

There is a single method, execute which will throttle the amount of gas per external call and limit the resulting output from each call to prevent malicious contracts from breaking the aggregate call.

Each result includes a status (0 for failure, 1 for successs) along with any result. A status of 0 may still return data, which will be the result of the revert.

License

MIT License.

About

A simple multicall contract and library wrapper to aggregate Ethereum calls.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published