- Contract name:
- Multicall
- Optimization enabled
- false
- Compiler version
- v0.8.0+commit.c7dfd78e
- EVM Version
- default
- Verified at
- 2022-01-18 02:35:11.565875Z
Contract source code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @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
0x608060405234801561001057600080fd5b50600436106100885760003560e01c806372425d9d1161005b57806372425d9d1461012a57806386d516e814610148578063a8b0574e14610166578063ee82ac5e1461018457610088565b80630f28c97d1461008d578063252dba42146100ab57806327e86d6e146100dc5780634d2301cc146100fa575b600080fd5b6100956101b4565b6040516100a2919061077d565b60405180910390f35b6100c560048036038101906100c091906105a6565b6101bc565b6040516100d3929190610798565b60405180910390f35b6100e46103a7565b6040516100f19190610762565b60405180910390f35b610114600480360381019061010f919061057d565b6103bc565b604051610121919061077d565b60405180910390f35b6101326103dd565b60405161013f919061077d565b60405180910390f35b6101506103e5565b60405161015d919061077d565b60405180910390f35b61016e6103ed565b60405161017b9190610747565b60405180910390f35b61019e600480360381019061019991906105e7565b6103f5565b6040516101ab9190610762565b60405180910390f35b600042905090565b60006060439150825167ffffffffffffffff811115610204577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405190808252806020026020018201604052801561023757816020015b60608152602001906001900390816102225790505b50905060005b83518110156103a157600080858381518110610282577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff168684815181106102dd577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151602001516040516102f69190610730565b6000604051808303816000865af19150503d8060008114610333576040519150601f19603f3d011682016040523d82523d6000602084013e610338565b606091505b50915091508161034757600080fd5b80848481518110610381577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101819052505050808061039990610971565b91505061023d565b50915091565b60006001436103b691906108b5565b40905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b600045905090565b600041905090565b600081409050919050565b600061041361040e846107f9565b6107c8565b9050808382526020820190508260005b8581101561045357813585016104398882610504565b845260208401935060208301925050600181019050610423565b5050509392505050565b600061047061046b84610825565b6107c8565b90508281526020810184848401111561048857600080fd5b61049384828561092f565b509392505050565b6000813590506104aa81610a29565b92915050565b600082601f8301126104c157600080fd5b81356104d1848260208601610400565b91505092915050565b600082601f8301126104eb57600080fd5b81356104fb84826020860161045d565b91505092915050565b60006040828403121561051657600080fd5b61052060406107c8565b905060006105308482850161049b565b600083015250602082013567ffffffffffffffff81111561055057600080fd5b61055c848285016104da565b60208301525092915050565b60008135905061057781610a40565b92915050565b60006020828403121561058f57600080fd5b600061059d8482850161049b565b91505092915050565b6000602082840312156105b857600080fd5b600082013567ffffffffffffffff8111156105d257600080fd5b6105de848285016104b0565b91505092915050565b6000602082840312156105f957600080fd5b600061060784828501610568565b91505092915050565b600061061c83836106b7565b905092915050565b61062d816108e9565b82525050565b600061063e82610865565b6106488185610888565b93508360208202850161065a85610855565b8060005b8581101561069657848403895281516106778582610610565b94506106828361087b565b925060208a0199505060018101905061065e565b50829750879550505050505092915050565b6106b1816108fb565b82525050565b60006106c282610870565b6106cc8185610899565b93506106dc81856020860161093e565b6106e581610a18565b840191505092915050565b60006106fb82610870565b61070581856108aa565b935061071581856020860161093e565b80840191505092915050565b61072a81610925565b82525050565b600061073c82846106f0565b915081905092915050565b600060208201905061075c6000830184610624565b92915050565b600060208201905061077760008301846106a8565b92915050565b60006020820190506107926000830184610721565b92915050565b60006040820190506107ad6000830185610721565b81810360208301526107bf8184610633565b90509392505050565b6000604051905081810181811067ffffffffffffffff821117156107ef576107ee6109e9565b5b8060405250919050565b600067ffffffffffffffff821115610814576108136109e9565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156108405761083f6109e9565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006108c082610925565b91506108cb83610925565b9250828210156108de576108dd6109ba565b5b828203905092915050565b60006108f482610905565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561095c578082015181840152602081019050610941565b8381111561096b576000848401525b50505050565b600061097c82610925565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156109af576109ae6109ba565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b610a32816108e9565b8114610a3d57600080fd5b50565b610a4981610925565b8114610a5457600080fd5b5056fea26469706673582212204b5a15734c2f03bcd36ea941aef8fc7fd3aea868982c9e04f6716b99939715b864736f6c63430008000033