Multicall3
Multicall3 enables batching multiple function calls into a single transaction, reducing gas costs and improving efficiency.
Structs
Call
Basic call struct.
struct Call {
address target;
bytes callData;
}
Call3
Call struct with allowFailure flag.
struct Call3 {
address target;
bool allowFailure;
bytes callData;
}
Call3Value
Call struct with value and allowFailure flag.
struct Call3Value {
address target;
bool allowFailure;
uint256 value;
bytes callData;
}
Result
Result struct for call returns.
struct Result {
bool success;
bytes returnData;
}
View Functions
getBasefee
Returns the current base fee.
function getBasefee() external view returns (uint256 basefee)
getBlockHash
Returns the hash of a specific block.
function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash)
getBlockNumber
Returns the current block number.
function getBlockNumber() external view returns (uint256 blockNumber)
getChainId
Returns the current chain ID.
function getChainId() external view returns (uint256 chainid)
getCurrentBlockCoinbase
Returns the current block coinbase.
function getCurrentBlockCoinbase() external view returns (address coinbase)
getCurrentBlockDifficulty
Returns the current block difficulty.
function getCurrentBlockDifficulty() external view returns (uint256 difficulty)
getCurrentBlockGasLimit
Returns the current block gas limit.
function getCurrentBlockGasLimit() external view returns (uint256 gaslimit)
getCurrentBlockTimestamp
Returns the current block timestamp.
function getCurrentBlockTimestamp() external view returns (uint256 timestamp)
getEthBalance
Returns the ETH balance of an address.
function getEthBalance(address addr) external view returns (uint256 balance)
getLastBlockHash
Returns the last block hash.
function getLastBlockHash() external view returns (bytes32 blockhash)
Functions
aggregate
Aggregate multiple calls in a single transaction.
function aggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes[] memory returnData)
aggregate3
Aggregate multiple calls with optional failure handling.
function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData)
aggregate3Value
Aggregate multiple calls with value and optional failure handling.
function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData)
blockAndAggregate
Aggregate calls and return block information.
function blockAndAggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)
tryAggregate
Try to aggregate calls with failure tolerance.
function tryAggregate(bool requireSuccess, Call[] calldata calls) external payable returns (Result[] memory returnData)
tryBlockAndAggregate
Try to aggregate calls with block information and failure tolerance.
function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls) external payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)