3.1.5 • Published 1 year ago
@plexswap/multicall v3.1.5
Plexswap Multicall
Enhanced multicall sdk to safely make multicalls within the gas limit.
Inspired by the 1inch multicall.
Install
$ pnpm add @plexswap/multicall @plexswap/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 '@plexswap/chains'
import { multicallByGasLimit, MulticallRequestWithGas } from '@plexswap/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 '@plexswap/chains'
import { getGasLimitOnChain } from '@plexswap/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.
3.1.3
1 year ago
3.1.2
1 year ago
3.1.1
1 year ago
3.1.5
1 year ago
2.0.5
1 year ago
2.0.3
2 years ago
2.0.4
2 years ago
2.0.2
2 years ago
2.0.1
2 years ago
1.1.23
2 years ago
1.1.22
2 years ago
1.1.21
2 years ago
1.1.7
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
3 years ago
1.0.15
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago