11.1.2 • Published 7 months ago
@monchain/multicall v11.1.2
Pancake Multicall
Enhanced multicall sdk to safely make multicalls within the gas limit.
Inspired by the 1inch multicall.
Install
$ pnpm add @pancakeswap/multicall @pancakeswap/sdk viemUsage
Basic usage
By default the calls will be splitted into chunks based on gas limit of each call and the rpc call gas limit of the chain
import { ChainId } from '@pancakeswap/chains'
import { multicallByGasLimit, MulticallRequestWithGas } from '@pancakeswap/multicall'
const calls: MulticallRequestWithGas[] = [
{
// Target contract to call
target: '0x',
// Encoded call data
callData: '',
// The maximum gas limit set to this single call
gasLimit: 1_000_000,
},
]
const { results, blockNumber } = await multicallByGasLimit(calls, {
chainId: ChainId.BSC,
// Rpc client. Please refer to `PublicClient` from viem
client,
})
for (const { success, result, gasUsed } of results) {
if (success) {
// Decode result
decodeResult(result)
}
}Advanced usage
The rpc call gas limit can be overriden if provided. Once provided, the multicall sdk won't ask for the gas limit from on chain.
const { results, blockNumber } = await multicallByGasLimit(calls, {
chainId: ChainId.BSC,
client,
gasLimit: 150_000_000,
})Other utilities
Get multicall gas limit
import { ChainId } from '@pancakeswap/chains'
import { getGasLimitOnChain } from '@pancakeswap/multicall'
// Get the rpc call gas limit of the specified chain
const gasLimit = await getGasLimitOnChain(ChainId.BSC)Supported chains
For supported chains and contract addresses, please refer to multicall contracts.
11.1.2
7 months ago
11.1.1
7 months ago
11.2.0
7 months ago
11.1.0
7 months ago
11.0.13
8 months ago
11.0.12
8 months ago
11.0.11
8 months ago
11.0.10
8 months ago
11.0.9
8 months ago
11.0.8
8 months ago
11.0.7
8 months ago
11.0.6
8 months ago
11.0.5
8 months ago
11.0.4
8 months ago
11.0.3
8 months ago
11.0.2
8 months ago
11.0.1
8 months ago
11.0.0
8 months ago
5.0.0
8 months ago
3.7.0
8 months ago
4.1.1
8 months ago
4.1.0
8 months ago
4.0.0
8 months ago