Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Multicall2
- Optimization enabled
- true
- Compiler version
- v0.7.6+commit.7338295f
- Optimization runs
- 1000000
- EVM Version
- default
- Verified at
- 2023-09-18T13:59:03.847708Z
contracts/Multicall2.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; pragma experimental ABIEncoderV2; /// @title Multicall2 - 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 Multicall2 { struct Call { address target; bytes callData; } struct Result { bool success; bytes returnData; } 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, "Multicall aggregate: call failed"); returnData[i] = ret; } } function blockAndAggregate(Call[] memory calls) public returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) { (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls); } function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) { blockHash = blockhash(blockNumber); } function getBlockNumber() public view returns (uint256 blockNumber) { blockNumber = block.number; } function getCurrentBlockCoinbase() public view returns (address coinbase) { coinbase = block.coinbase; } function getCurrentBlockDifficulty() public view returns (uint256 difficulty) { difficulty = block.difficulty; } function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) { gaslimit = block.gaslimit; } function getCurrentBlockTimestamp() public view returns (uint256 timestamp) { timestamp = block.timestamp; } function getEthBalance(address addr) public view returns (uint256 balance) { balance = addr.balance; } function getLastBlockHash() public view returns (bytes32 blockHash) { blockHash = blockhash(block.number - 1); } function tryAggregate(bool requireSuccess, Call[] memory calls) public returns (Result[] memory returnData) { returnData = new Result[](calls.length); for(uint256 i = 0; i < calls.length; i++) { (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData); if (requireSuccess) { require(success, "Multicall2 aggregate: call failed"); } returnData[i] = Result(success, ret); } } function tryBlockAndAggregate(bool requireSuccess, Call[] memory calls) public returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData) { blockNumber = block.number; blockHash = blockhash(block.number); returnData = tryAggregate(requireSuccess, calls); } }
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":1000000,"enabled":true},"metadata":{"bytecodeHash":"none"},"libraries":{}}
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 Multicall2.Call[]","components":[{"type":"address","name":"target","internalType":"address"},{"type":"bytes","name":"callData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"},{"type":"bytes32","name":"blockHash","internalType":"bytes32"},{"type":"tuple[]","name":"returnData","internalType":"struct Multicall2.Result[]","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"bytes","name":"returnData","internalType":"bytes"}]}],"name":"blockAndAggregate","inputs":[{"type":"tuple[]","name":"calls","internalType":"struct Multicall2.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":"uint256","name":"blockNumber","internalType":"uint256"}],"name":"getBlockNumber","inputs":[]},{"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":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"tuple[]","name":"returnData","internalType":"struct Multicall2.Result[]","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"bytes","name":"returnData","internalType":"bytes"}]}],"name":"tryAggregate","inputs":[{"type":"bool","name":"requireSuccess","internalType":"bool"},{"type":"tuple[]","name":"calls","internalType":"struct Multicall2.Call[]","components":[{"type":"address","name":"target","internalType":"address"},{"type":"bytes","name":"callData","internalType":"bytes"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"blockNumber","internalType":"uint256"},{"type":"bytes32","name":"blockHash","internalType":"bytes32"},{"type":"tuple[]","name":"returnData","internalType":"struct Multicall2.Result[]","components":[{"type":"bool","name":"success","internalType":"bool"},{"type":"bytes","name":"returnData","internalType":"bytes"}]}],"name":"tryBlockAndAggregate","inputs":[{"type":"bool","name":"requireSuccess","internalType":"bool"},{"type":"tuple[]","name":"calls","internalType":"struct Multicall2.Call[]","components":[{"type":"address","name":"target","internalType":"address"},{"type":"bytes","name":"callData","internalType":"bytes"}]}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50610a3c806100206000396000f3fe608060405234801561001057600080fd5b50600436106100d45760003560e01c806372425d9d11610081578063bce38bd71161005b578063bce38bd714610182578063c3077fa9146101a2578063ee82ac5e146101b5576100d4565b806372425d9d1461015d57806386d516e814610165578063a8b0574e1461016d576100d4565b8063399542e9116100b2578063399542e91461012057806342cbb15c146101425780634d2301cc1461014a576100d4565b80630f28c97d146100d9578063252dba42146100f757806327e86d6e14610118575b600080fd5b6100e16101c8565b6040516100ee9190610892565b60405180910390f35b61010a6101053660046106c9565b6101cc565b6040516100ee92919061092d565b6100e1610331565b61013361012e366004610704565b610358565b6040516100ee939291906109b3565b6100e1610370565b6100e16101583660046106a8565b610374565b6100e161038e565b6100e1610392565b610175610396565b6040516100ee919061085e565b610195610190366004610704565b61039a565b6040516100ee919061087f565b6101336101b03660046106c9565b610516565b6100e16101c3366004610756565b610533565b4290565b8051439060609067ffffffffffffffff811180156101e957600080fd5b5060405190808252806020026020018201604052801561021d57816020015b60608152602001906001900390816102085790505b50905060005b835181101561032b5760008085838151811061023b57fe5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1686848151811061026957fe5b6020026020010151602001516040516102829190610842565b6000604051808303816000865af19150503d80600081146102bf576040519150601f19603f3d011682016040523d82523d6000602084013e6102c4565b606091505b509150915081610309576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610300906108f8565b60405180910390fd5b8084848151811061031657fe5b60209081029190910101525050600101610223565b50915091565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff43014090565b4380406060610367858561039a565b90509250925092565b4390565b73ffffffffffffffffffffffffffffffffffffffff163190565b4490565b4590565b4190565b6060815167ffffffffffffffff811180156103b457600080fd5b506040519080825280602002602001820160405280156103ee57816020015b6103db610537565b8152602001906001900390816103d35790505b50905060005b825181101561050f5760008084838151811061040c57fe5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1685848151811061043a57fe5b6020026020010151602001516040516104539190610842565b6000604051808303816000865af19150503d8060008114610490576040519150601f19603f3d011682016040523d82523d6000602084013e610495565b606091505b509150915085156104d757816104d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103009061089b565b60405180604001604052808315158152602001828152508484815181106104fa57fe5b602090810291909101015250506001016103f4565b5092915050565b6000806060610526600185610358565b9196909550909350915050565b4090565b60408051808201909152600081526060602082015290565b803573ffffffffffffffffffffffffffffffffffffffff8116811461057357600080fd5b919050565b600082601f830112610588578081fd5b8135602067ffffffffffffffff8083111561059f57fe5b6105ac82838502016109db565b83815282810190868401865b8681101561069a578135890160407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08181848f030112156105f7578a8bfd5b81518281018181108a8211171561060a57fe5b8352610617848b0161054f565b81528284013589811115610629578c8dfd5b8085019450508d603f85011261063d578b8cfd5b898401358981111561064b57fe5b61065b8b84601f840116016109db565b92508083528e84828701011115610670578c8dfd5b808486018c85013782018a018c9052808a01919091528652505092850192908501906001016105b8565b509098975050505050505050565b6000602082840312156106b9578081fd5b6106c28261054f565b9392505050565b6000602082840312156106da578081fd5b813567ffffffffffffffff8111156106f0578182fd5b6106fc84828501610578565b949350505050565b60008060408385031215610716578081fd5b82358015158114610725578182fd5b9150602083013567ffffffffffffffff811115610740578182fd5b61074c85828601610578565b9150509250929050565b600060208284031215610767578081fd5b5035919050565b60008282518085526020808601955080818302840101818601855b848110156107eb578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018952815180511515845284015160408585018190526107d7818601836107f8565b9a86019a9450505090830190600101610789565b5090979650505050505050565b600081518084526108108160208601602086016109ff565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082516108548184602087016109ff565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6000602082526106c2602083018461076e565b90815260200190565b60208082526021908201527f4d756c746963616c6c32206167677265676174653a2063616c6c206661696c6560408201527f6400000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f4d756c746963616c6c206167677265676174653a2063616c6c206661696c6564604082015260600190565b600060408201848352602060408185015281855180845260608601915060608382028701019350828701855b828110156109a5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08887030184526109938683516107f8565b95509284019290840190600101610959565b509398975050505050505050565b6000848252836020830152606060408301526109d2606083018461076e565b95945050505050565b60405181810167ffffffffffffffff811182821017156109f757fe5b604052919050565b60005b83811015610a1a578181015183820152602001610a02565b83811115610a29576000848401525b5050505056fea164736f6c6343000706000a
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100d45760003560e01c806372425d9d11610081578063bce38bd71161005b578063bce38bd714610182578063c3077fa9146101a2578063ee82ac5e146101b5576100d4565b806372425d9d1461015d57806386d516e814610165578063a8b0574e1461016d576100d4565b8063399542e9116100b2578063399542e91461012057806342cbb15c146101425780634d2301cc1461014a576100d4565b80630f28c97d146100d9578063252dba42146100f757806327e86d6e14610118575b600080fd5b6100e16101c8565b6040516100ee9190610892565b60405180910390f35b61010a6101053660046106c9565b6101cc565b6040516100ee92919061092d565b6100e1610331565b61013361012e366004610704565b610358565b6040516100ee939291906109b3565b6100e1610370565b6100e16101583660046106a8565b610374565b6100e161038e565b6100e1610392565b610175610396565b6040516100ee919061085e565b610195610190366004610704565b61039a565b6040516100ee919061087f565b6101336101b03660046106c9565b610516565b6100e16101c3366004610756565b610533565b4290565b8051439060609067ffffffffffffffff811180156101e957600080fd5b5060405190808252806020026020018201604052801561021d57816020015b60608152602001906001900390816102085790505b50905060005b835181101561032b5760008085838151811061023b57fe5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1686848151811061026957fe5b6020026020010151602001516040516102829190610842565b6000604051808303816000865af19150503d80600081146102bf576040519150601f19603f3d011682016040523d82523d6000602084013e6102c4565b606091505b509150915081610309576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610300906108f8565b60405180910390fd5b8084848151811061031657fe5b60209081029190910101525050600101610223565b50915091565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff43014090565b4380406060610367858561039a565b90509250925092565b4390565b73ffffffffffffffffffffffffffffffffffffffff163190565b4490565b4590565b4190565b6060815167ffffffffffffffff811180156103b457600080fd5b506040519080825280602002602001820160405280156103ee57816020015b6103db610537565b8152602001906001900390816103d35790505b50905060005b825181101561050f5760008084838151811061040c57fe5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1685848151811061043a57fe5b6020026020010151602001516040516104539190610842565b6000604051808303816000865af19150503d8060008114610490576040519150601f19603f3d011682016040523d82523d6000602084013e610495565b606091505b509150915085156104d757816104d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103009061089b565b60405180604001604052808315158152602001828152508484815181106104fa57fe5b602090810291909101015250506001016103f4565b5092915050565b6000806060610526600185610358565b9196909550909350915050565b4090565b60408051808201909152600081526060602082015290565b803573ffffffffffffffffffffffffffffffffffffffff8116811461057357600080fd5b919050565b600082601f830112610588578081fd5b8135602067ffffffffffffffff8083111561059f57fe5b6105ac82838502016109db565b83815282810190868401865b8681101561069a578135890160407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08181848f030112156105f7578a8bfd5b81518281018181108a8211171561060a57fe5b8352610617848b0161054f565b81528284013589811115610629578c8dfd5b8085019450508d603f85011261063d578b8cfd5b898401358981111561064b57fe5b61065b8b84601f840116016109db565b92508083528e84828701011115610670578c8dfd5b808486018c85013782018a018c9052808a01919091528652505092850192908501906001016105b8565b509098975050505050505050565b6000602082840312156106b9578081fd5b6106c28261054f565b9392505050565b6000602082840312156106da578081fd5b813567ffffffffffffffff8111156106f0578182fd5b6106fc84828501610578565b949350505050565b60008060408385031215610716578081fd5b82358015158114610725578182fd5b9150602083013567ffffffffffffffff811115610740578182fd5b61074c85828601610578565b9150509250929050565b600060208284031215610767578081fd5b5035919050565b60008282518085526020808601955080818302840101818601855b848110156107eb578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018952815180511515845284015160408585018190526107d7818601836107f8565b9a86019a9450505090830190600101610789565b5090979650505050505050565b600081518084526108108160208601602086016109ff565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082516108548184602087016109ff565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b6000602082526106c2602083018461076e565b90815260200190565b60208082526021908201527f4d756c746963616c6c32206167677265676174653a2063616c6c206661696c6560408201527f6400000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f4d756c746963616c6c206167677265676174653a2063616c6c206661696c6564604082015260600190565b600060408201848352602060408185015281855180845260608601915060608382028701019350828701855b828110156109a5577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa08887030184526109938683516107f8565b95509284019290840190600101610959565b509398975050505050505050565b6000848252836020830152606060408301526109d2606083018461076e565b95945050505050565b60405181810167ffffffffffffffff811182821017156109f757fe5b604052919050565b60005b83811015610a1a578181015183820152602001610a02565b83811115610a29576000848401525b5050505056fea164736f6c6343000706000a