Skip to content

multicallSameContract

multicallSameContract(provider, contractAddress, abi, calls): Promise<MulticallResult[]>

Defined in: utils/multicall.ts:291

Convenience function for calling multiple functions on the same contract via Multicall3.

Parameters

provider

MulticallProvider

An essential-eth provider

contractAddress

string

The address of the target contract

abi

JSONABI

The JSON ABI of the target contract

calls

object[]

Array of function calls — each specifies a function name and optional args

Returns

Promise<MulticallResult[]>

Array of results in the same order as the input calls

Example

import { JsonRpcProvider, multicallSameContract } from 'essential-eth';
const provider = new JsonRpcProvider('https://free-eth-node.com/api/eth');
const results = await multicallSameContract(
provider,
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
daiAbi,
[
{ functionName: 'name' },
{ functionName: 'symbol' },
{ functionName: 'decimals' },
{ functionName: 'balanceOf', args: ['0x...'] },
],
);