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.6.12+commit.27d51765
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2022-01-18T01:16:22.933986Z
Contract source code
/** *Submitted for verification at polygonscan.com on 2021-08-16 */ 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); } }
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
0x608060405234801561001057600080fd5b50610939806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806372425d9d1161007157806372425d9d1461013d57806386d516e814610145578063a8b0574e1461014d578063bce38bd714610162578063c3077fa914610182578063ee82ac5e14610195576100b4565b80630f28c97d146100b9578063252dba42146100d757806327e86d6e146100f8578063399542e91461010057806342cbb15c146101225780634d2301cc1461012a575b600080fd5b6100c16101a8565b6040516100ce919061079d565b60405180910390f35b6100ea6100e5366004610620565b6101ac565b6040516100ce92919061081c565b6100c16102eb565b61011361010e36600461065b565b6102f4565b6040516100ce93929190610884565b6100c161030c565b6100c16101383660046105fe565b610310565b6100c161031d565b6100c1610321565b610155610325565b6040516100ce9190610776565b61017561017036600461065b565b610329565b6040516100ce919061078a565b610113610190366004610620565b61047f565b6100c16101a33660046106ad565b61049c565b4290565b8051439060609067ffffffffffffffff811180156101c957600080fd5b506040519080825280602002602001820160405280156101fd57816020015b60608152602001906001900390816101e85790505b50905060005b83518110156102e5576000606085838151811061021c57fe5b6020026020010151600001516001600160a01b031686848151811061023d57fe5b602002602001015160200151604051610256919061075a565b6000604051808303816000865af19150503d8060008114610293576040519150601f19603f3d011682016040523d82523d6000602084013e610298565b606091505b5091509150816102c35760405162461bcd60e51b81526004016102ba906107e7565b60405180910390fd5b808484815181106102d057fe5b60209081029190910101525050600101610203565b50915091565b60001943014090565b43804060606103038585610329565b90509250925092565b4390565b6001600160a01b03163190565b4490565b4590565b4190565b6060815167ffffffffffffffff8111801561034357600080fd5b5060405190808252806020026020018201604052801561037d57816020015b61036a6104a0565b8152602001906001900390816103625790505b50905060005b8251811015610478576000606084838151811061039c57fe5b6020026020010151600001516001600160a01b03168584815181106103bd57fe5b6020026020010151602001516040516103d6919061075a565b6000604051808303816000865af19150503d8060008114610413576040519150601f19603f3d011682016040523d82523d6000602084013e610418565b606091505b5091509150851561044057816104405760405162461bcd60e51b81526004016102ba906107a6565b604051806040016040528083151581526020018281525084848151811061046357fe5b60209081029190910101525050600101610383565b5092915050565b600080606061048f6001856102f4565b9196909550909350915050565b4090565b60408051808201909152600081526060602082015290565b80356001600160a01b03811681146104cf57600080fd5b92915050565b600082601f8301126104e5578081fd5b813567ffffffffffffffff808211156104fc578283fd5b602061050b81828502016108ac565b838152935080840185820160005b858110156105895781358801604080601f19838d0301121561053a57600080fd5b610543816108ac565b61054f8c8885016104b8565b815290820135908782111561056357600080fd5b6105718c8884860101610595565b81880152855250509183019190830190600101610519565b50505050505092915050565b600082601f8301126105a5578081fd5b813567ffffffffffffffff8111156105bb578182fd5b6105ce601f8201601f19166020016108ac565b91508082528360208285010111156105e557600080fd5b8060208401602084013760009082016020015292915050565b60006020828403121561060f578081fd5b61061983836104b8565b9392505050565b600060208284031215610631578081fd5b813567ffffffffffffffff811115610647578182fd5b610653848285016104d5565b949350505050565b6000806040838503121561066d578081fd5b8235801515811461067c578182fd5b9150602083013567ffffffffffffffff811115610697578182fd5b6106a3858286016104d5565b9150509250929050565b6000602082840312156106be578081fd5b5035919050565b6000815180845260208085018081965082840281019150828601855b858110156107215782840389528151805115158552850151604086860181905261070d8187018361072e565b9a87019a95505050908401906001016106e1565b5091979650505050505050565b600081518084526107468160208601602086016108d3565b601f01601f19169290920160200192915050565b6000825161076c8184602087016108d3565b9190910192915050565b6001600160a01b0391909116815260200190565b60006020825261061960208301846106c5565b90815260200190565b60208082526021908201527f4d756c746963616c6c32206167677265676174653a2063616c6c206661696c656040820152601960fa1b606082015260800190565b6020808252818101527f4d756c746963616c6c206167677265676174653a2063616c6c206661696c6564604082015260600190565b600060408201848352602060408185015281855180845260608601915060608382028701019350828701855b8281101561087657605f1988870301845261086486835161072e565b95509284019290840190600101610848565b509398975050505050505050565b6000848252836020830152606060408301526108a360608301846106c5565b95945050505050565b60405181810167ffffffffffffffff811182821017156108cb57600080fd5b604052919050565b60005b838110156108ee5781810151838201526020016108d6565b838111156108fd576000848401525b5050505056fea264697066735822122005d9de7b9f4ef5298e9ae887ce58b54e1f8a779e70f96e38f5f4435649053a0e64736f6c634300060c0033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806372425d9d1161007157806372425d9d1461013d57806386d516e814610145578063a8b0574e1461014d578063bce38bd714610162578063c3077fa914610182578063ee82ac5e14610195576100b4565b80630f28c97d146100b9578063252dba42146100d757806327e86d6e146100f8578063399542e91461010057806342cbb15c146101225780634d2301cc1461012a575b600080fd5b6100c16101a8565b6040516100ce919061079d565b60405180910390f35b6100ea6100e5366004610620565b6101ac565b6040516100ce92919061081c565b6100c16102eb565b61011361010e36600461065b565b6102f4565b6040516100ce93929190610884565b6100c161030c565b6100c16101383660046105fe565b610310565b6100c161031d565b6100c1610321565b610155610325565b6040516100ce9190610776565b61017561017036600461065b565b610329565b6040516100ce919061078a565b610113610190366004610620565b61047f565b6100c16101a33660046106ad565b61049c565b4290565b8051439060609067ffffffffffffffff811180156101c957600080fd5b506040519080825280602002602001820160405280156101fd57816020015b60608152602001906001900390816101e85790505b50905060005b83518110156102e5576000606085838151811061021c57fe5b6020026020010151600001516001600160a01b031686848151811061023d57fe5b602002602001015160200151604051610256919061075a565b6000604051808303816000865af19150503d8060008114610293576040519150601f19603f3d011682016040523d82523d6000602084013e610298565b606091505b5091509150816102c35760405162461bcd60e51b81526004016102ba906107e7565b60405180910390fd5b808484815181106102d057fe5b60209081029190910101525050600101610203565b50915091565b60001943014090565b43804060606103038585610329565b90509250925092565b4390565b6001600160a01b03163190565b4490565b4590565b4190565b6060815167ffffffffffffffff8111801561034357600080fd5b5060405190808252806020026020018201604052801561037d57816020015b61036a6104a0565b8152602001906001900390816103625790505b50905060005b8251811015610478576000606084838151811061039c57fe5b6020026020010151600001516001600160a01b03168584815181106103bd57fe5b6020026020010151602001516040516103d6919061075a565b6000604051808303816000865af19150503d8060008114610413576040519150601f19603f3d011682016040523d82523d6000602084013e610418565b606091505b5091509150851561044057816104405760405162461bcd60e51b81526004016102ba906107a6565b604051806040016040528083151581526020018281525084848151811061046357fe5b60209081029190910101525050600101610383565b5092915050565b600080606061048f6001856102f4565b9196909550909350915050565b4090565b60408051808201909152600081526060602082015290565b80356001600160a01b03811681146104cf57600080fd5b92915050565b600082601f8301126104e5578081fd5b813567ffffffffffffffff808211156104fc578283fd5b602061050b81828502016108ac565b838152935080840185820160005b858110156105895781358801604080601f19838d0301121561053a57600080fd5b610543816108ac565b61054f8c8885016104b8565b815290820135908782111561056357600080fd5b6105718c8884860101610595565b81880152855250509183019190830190600101610519565b50505050505092915050565b600082601f8301126105a5578081fd5b813567ffffffffffffffff8111156105bb578182fd5b6105ce601f8201601f19166020016108ac565b91508082528360208285010111156105e557600080fd5b8060208401602084013760009082016020015292915050565b60006020828403121561060f578081fd5b61061983836104b8565b9392505050565b600060208284031215610631578081fd5b813567ffffffffffffffff811115610647578182fd5b610653848285016104d5565b949350505050565b6000806040838503121561066d578081fd5b8235801515811461067c578182fd5b9150602083013567ffffffffffffffff811115610697578182fd5b6106a3858286016104d5565b9150509250929050565b6000602082840312156106be578081fd5b5035919050565b6000815180845260208085018081965082840281019150828601855b858110156107215782840389528151805115158552850151604086860181905261070d8187018361072e565b9a87019a95505050908401906001016106e1565b5091979650505050505050565b600081518084526107468160208601602086016108d3565b601f01601f19169290920160200192915050565b6000825161076c8184602087016108d3565b9190910192915050565b6001600160a01b0391909116815260200190565b60006020825261061960208301846106c5565b90815260200190565b60208082526021908201527f4d756c746963616c6c32206167677265676174653a2063616c6c206661696c656040820152601960fa1b606082015260800190565b6020808252818101527f4d756c746963616c6c206167677265676174653a2063616c6c206661696c6564604082015260600190565b600060408201848352602060408185015281855180845260608601915060608382028701019350828701855b8281101561087657605f1988870301845261086486835161072e565b95509284019290840190600101610848565b509398975050505050505050565b6000848252836020830152606060408301526108a360608301846106c5565b95945050505050565b60405181810167ffffffffffffffff811182821017156108cb57600080fd5b604052919050565b60005b838110156108ee5781810151838201526020016108d6565b838111156108fd576000848401525b5050505056fea264697066735822122005d9de7b9f4ef5298e9ae887ce58b54e1f8a779e70f96e38f5f4435649053a0e64736f6c634300060c0033