- Contract name:
- Multicall
- Optimization enabled
- true
- Compiler version
- v0.8.9+commit.e5eed63a
- Optimization runs
- 999999
- EVM Version
- default
- Verified at
- 2022-05-25 19:51:39.087211Z
Contract source code
// Sources flattened with hardhat v2.8.4 https://hardhat.org
// File contracts/Multicall.sol
// SPDX-License-Identifier: MIT
// Derived from https://github.com/makerdao/multicall/blob/master/src/Multicall.sol
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
/// @title Multicall - Aggregate results from multiple read-only function calls
/// @author Michael Elliot <mike@makerdao.com>
/// @author Joshua Levine <joshua@makerdao.com>
/// @author Nick Johnson <arachnid@notdot.net>
contract Multicall {
struct Call {
address target;
bytes callData;
}
function aggregate(Call[] memory calls)
public
returns (uint256 blockNumber, bytes[] memory returnData)
{
blockNumber = block.number;
returnData = new bytes[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory ret) = calls[i].target.call(
calls[i].callData
);
require(success);
returnData[i] = ret;
}
}
// Helper functions
function getEthBalance(address addr) public view returns (uint256 balance) {
balance = addr.balance;
}
function getBlockHash(uint256 blockNumber)
public
view
returns (bytes32 blockHash)
{
blockHash = blockhash(blockNumber);
}
function getLastBlockHash() public view returns (bytes32 blockHash) {
blockHash = blockhash(block.number - 1);
}
function getCurrentBlockTimestamp()
public
view
returns (uint256 timestamp)
{
timestamp = block.timestamp;
}
function getCurrentBlockDifficulty()
public
view
returns (uint256 difficulty)
{
difficulty = block.difficulty;
}
function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {
gaslimit = block.gaslimit;
}
function getCurrentBlockCoinbase() public view returns (address coinbase) {
coinbase = block.coinbase;
}
}
Contract ABI
[{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"},{"type":"bytes[]","name":"returnData","internalType":"bytes[]"}],"name":"aggregate","inputs":[{"type":"tuple[]","name":"calls","internalType":"struct Multicall.Call[]","components":[{"type":"address","name":"target","internalType":"address"},{"type":"bytes","name":"callData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"blockHash","internalType":"bytes32"}],"name":"getBlockHash","inputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"coinbase","internalType":"address"}],"name":"getCurrentBlockCoinbase","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"difficulty","internalType":"uint256"}],"name":"getCurrentBlockDifficulty","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"gaslimit","internalType":"uint256"}],"name":"getCurrentBlockGasLimit","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"timestamp","internalType":"uint256"}],"name":"getCurrentBlockTimestamp","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"balance","internalType":"uint256"}],"name":"getEthBalance","inputs":[{"type":"address","name":"addr","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"blockHash","internalType":"bytes32"}],"name":"getLastBlockHash","inputs":[]}]
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c806372425d9d1161005b57806372425d9d146100f357806386d516e8146100f9578063a8b0574e146100ff578063ee82ac5e1461010d57600080fd5b80630f28c97d1461008d578063252dba42146100a257806327e86d6e146100c35780634d2301cc146100cb575b600080fd5b425b6040519081526020015b60405180910390f35b6100b56100b036600461034f565b61011f565b6040516100999291906104fb565b61008f61026c565b61008f6100d93660046105b9565b73ffffffffffffffffffffffffffffffffffffffff163190565b4461008f565b4561008f565b604051418152602001610099565b61008f61011b3660046105db565b4090565b8051439060609067ffffffffffffffff81111561013e5761013e61027f565b60405190808252806020026020018201604052801561017157816020015b606081526020019060019003908161015c5790505b50905060005b835181101561026657600080858381518110610195576101956105f4565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff168684815181106101c9576101c96105f4565b6020026020010151602001516040516101e29190610623565b6000604051808303816000865af19150503d806000811461021f576040519150601f19603f3d011682016040523d82523d6000602084013e610224565b606091505b50915091508161023357600080fd5b80848481518110610246576102466105f4565b60200260200101819052505050808061025e9061066e565b915050610177565b50915091565b60006102796001436106a7565b40905090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156102d1576102d161027f565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561031e5761031e61027f565b604052919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461034a57600080fd5b919050565b6000602080838503121561036257600080fd5b823567ffffffffffffffff8082111561037a57600080fd5b818501915085601f83011261038e57600080fd5b8135818111156103a0576103a061027f565b8060051b6103af8582016102d7565b91825283810185019185810190898411156103c957600080fd5b86860192505b838310156104be578235858111156103e75760008081fd5b860160407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0828d03810182131561041e5760008081fd5b6104266102ae565b6104318b8501610326565b815282840135898111156104455760008081fd5b8085019450508d603f85011261045b5760008081fd5b8a8401358981111561046f5761046f61027f565b61047f8c84601f840116016102d7565b92508083528e848287010111156104965760008081fd5b808486018d85013760009083018c0152808b01919091528452505091860191908601906103cf565b9998505050505050505050565b60005b838110156104e65781810151838201526020016104ce565b838111156104f5576000848401525b50505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b828110156105ab577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08887030184528151805180885261056e81888a018985016104cb565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01696909601850195509284019290840190600101610529565b509398975050505050505050565b6000602082840312156105cb57600080fd5b6105d482610326565b9392505050565b6000602082840312156105ed57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082516106358184602087016104cb565b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156106a0576106a061063f565b5060010190565b6000828210156106b9576106b961063f565b50039056fea2646970667358221220f668613be37b8d80ee1ae972bcd04b91acb5884d4b8bd5659490119bd973274364736f6c63430008090033