Our v2 has been released in public beta. Check it out here and our announcement blog here!

Multicall2

0xd1dC5CF410b227dFEeFEe8D3c1C9DB4FBE66d362
copy address
qr
label
download csv
Balance0 TT - $0
Transactions1
Contract Creation0x108d050b...at0x015c509f...
Contract NameMulticall2
Compiler Versionv0.8.9+commit.e5eed63a
Optimizedtrue
Optimizer Runs200
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-License-Identifier: MIT
pragma solidity 0.8.9;

/**
 * Fork from https://github.com/makerdao/multicall/blob/master/src/Multicall2.sol
 *
 * @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);
    }
}
ABI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
[
  {
    "inputs": [
      {
        "components": [
          {
            "internalType": "address",
            "name": "target",
            "type": "address"
          },
          {
            "internalType": "bytes",
            "name": "callData",
            "type": "bytes"
          }
        ],
        "internalType": "struct Multicall2.Call[]",
        "name": "calls",
        "type": "tuple[]"
      }
    ],
    "name": "aggregate",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "blockNumber",
        "type": "uint256"
      },
      {
        "internalType": "bytes[]",
        "name": "returnData",
        "type": "bytes[]"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "components": [
          {
            "internalType": "address",
            "name": "target",
            "type": "address"
          },
          {
            "internalType": "bytes",
            "name": "callData",
            "type": "bytes"
          }
        ],
        "internalType": "struct Multicall2.Call[]",
        "name": "calls",
        "type": "tuple[]"
      }
    ],
    "name": "blockAndAggregate",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "blockNumber",
        "type": "uint256"
      },
      {
        "internalType": "bytes32",
        "name": "blockHash",
        "type": "bytes32"
      },
      {
        "components": [
          {
            "internalType": "bool",
            "name": "success",
            "type": "bool"
          },
          {
            "internalType": "bytes",
            "name": "returnData",
            "type": "bytes"
          }
        ],
        "internalType": "struct Multicall2.Result[]",
        "name": "returnData",
        "type": "tuple[]"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "blockNumber",
        "type": "uint256"
      }
    ],
    "name": "getBlockHash",
    "outputs": [
      {
        "internalType": "bytes32",
        "name": "blockHash",
        "type": "bytes32"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "getBlockNumber",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "blockNumber",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "getCurrentBlockCoinbase",
    "outputs": [
      {
        "internalType": "address",
        "name": "coinbase",
        "type": "address"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "getCurrentBlockDifficulty",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "difficulty",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "getCurrentBlockGasLimit",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "gaslimit",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "getCurrentBlockTimestamp",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "timestamp",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "addr",
        "type": "address"
      }
    ],
    "name": "getEthBalance",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "balance",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "getLastBlockHash",
    "outputs": [
      {
        "internalType": "bytes32",
        "name": "blockHash",
        "type": "bytes32"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bool",
        "name": "requireSuccess",
        "type": "bool"
      },
      {
        "components": [
          {
            "internalType": "address",
            "name": "target",
            "type": "address"
          },
          {
            "internalType": "bytes",
            "name": "callData",
            "type": "bytes"
          }
        ],
        "internalType": "struct Multicall2.Call[]",
        "name": "calls",
        "type": "tuple[]"
      }
    ],
    "name": "tryAggregate",
    "outputs": [
      {
        "components": [
          {
            "internalType": "bool",
            "name": "success",
            "type": "bool"
          },
          {
            "internalType": "bytes",
            "name": "returnData",
            "type": "bytes"
          }
        ],
        "internalType": "struct Multicall2.Result[]",
        "name": "returnData",
        "type": "tuple[]"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "bool",
        "name": "requireSuccess",
        "type": "bool"
      },
      {
        "components": [
          {
            "internalType": "address",
            "name": "target",
            "type": "address"
          },
          {
            "internalType": "bytes",
            "name": "callData",
            "type": "bytes"
          }
        ],
        "internalType": "struct Multicall2.Call[]",
        "name": "calls",
        "type": "tuple[]"
      }
    ],
    "name": "tryBlockAndAggregate",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "blockNumber",
        "type": "uint256"
      },
      {
        "internalType": "bytes32",
        "name": "blockHash",
        "type": "bytes32"
      },
      {
        "components": [
          {
            "internalType": "bool",
            "name": "success",
            "type": "bool"
          },
          {
            "internalType": "bytes",
            "name": "returnData",
            "type": "bytes"
          }
        ],
        "internalType": "struct Multicall2.Result[]",
        "name": "returnData",
        "type": "tuple[]"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]
Creation Bytecode
1
0x608060405234801561001057600080fd5b50600436106100d1576000357c01000000000000000000000000000000000000000000000000000000009004806372425d9d1161008e57806372425d9d1461016457806386d516e81461016a578063a8b0574e14610170578063bce38bd71461017e578063c3077fa91461019e578063ee82ac5e146101b157600080fd5b80630f28c97d146100d6578063252dba42146100eb57806327e86d6e1461010c578063399542e91461011457806342cbb15c146101365780634d2301cc1461013c575b600080fd5b425b6040519081526020015b60405180910390f35b6100fe6100f93660046107a3565b6101c3565b6040516100e292919061083c565b6100d8610372565b6101276101223660046108a5565b610385565b6040516100e293929190610961565b436100d8565b6100d861014a366004610989565b73ffffffffffffffffffffffffffffffffffffffff163190565b446100d8565b456100d8565b6040514181526020016100e2565b61019161018c3660046108a5565b61039d565b6040516100e291906109ab565b6101276101ac3660046107a3565b61059a565b6100d86101bf3660046109be565b4090565b8051439060609067ffffffffffffffff8111156101e2576101e26105b7565b60405190808252806020026020018201604052801561021557816020015b60608152602001906001900390816102005790505b50905060005b835181101561036c57600080858381518110610239576102396109d7565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1686848151811061026d5761026d6109d7565b6020026020010151602001516040516102869190610a06565b6000604051808303816000865af19150503d80600081146102c3576040519150601f19603f3d011682016040523d82523d6000602084013e6102c8565b606091505b509150915081610339576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4d756c746963616c6c206167677265676174653a2063616c6c206661696c656460448201526064015b60405180910390fd5b8084848151811061034c5761034c6109d7565b60200260200101819052505050808061036490610a51565b91505061021b565b50915091565b600061037f600143610a6c565b40905090565b4380406060610394858561039d565b90509250925092565b6060815167ffffffffffffffff8111156103b9576103b96105b7565b6040519080825280602002602001820160405280156103ff57816020015b6040805180820190915260008152606060208201528152602001906001900390816103d75790505b50905060005b825181101561059357600080848381518110610423576104236109d7565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff16858481518110610457576104576109d7565b6020026020010151602001516040516104709190610a06565b6000604051808303816000865af19150503d80600081146104ad576040519150601f19603f3d011682016040523d82523d6000602084013e6104b2565b606091505b5091509150851561054a578161054a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4d756c746963616c6c32206167677265676174653a2063616c6c206661696c6560448201527f64000000000000000000000000000000000000000000000000000000000000006064820152608401610330565b6040518060400160405280831515815260200182815250848481518110610573576105736109d7565b60200260200101819052505050808061058b90610a51565b915050610405565b5092915050565b60008060606105aa600185610385565b9196909550909350915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715610609576106096105b7565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715610638576106386105b7565b604052919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461066457600080fd5b919050565b6000601f838184011261067b57600080fd5b8235602067ffffffffffffffff80831115610698576106986105b7565b8183026106a683820161060f565b93845286810183019383810190898611156106c057600080fd5b84890192505b85831015610796578235848111156106de5760008081fd5b89016040601f19828d0381018213156106f75760008081fd5b6106ff6105e6565b61070a898501610640565b8152828401358881111561071e5760008081fd5b8085019450508d603f8501126107345760008081fd5b8884013588811115610748576107486105b7565b6107578a848e8401160161060f565b92508083528e8482870101111561076e5760008081fd5b808486018b85013760009083018a0152808901919091528452505091840191908401906106c6565b9998505050505050505050565b6000602082840312156107b557600080fd5b813567ffffffffffffffff8111156107cc57600080fd5b6107d884828501610669565b949350505050565b60005b838110156107fb5781810151838201526020016107e3565b8381111561080a576000848401525b50505050565b600081518084526108288160208601602086016107e0565b601f01601f19169290920160200192915050565b60006040820184835260206040818501528185518084526060860191506060838202870101935082870160005b8281101561089757605f19888703018452610885868351610810565b95509284019290840190600101610869565b509398975050505050505050565b600080604083850312156108b857600080fd5b823580151581146108c857600080fd5b9150602083013567ffffffffffffffff8111156108e457600080fd5b6108f085828601610669565b9150509250929050565b600081518084526020808501945084818302860182860160005b858110156109545783830389528151805115158452850151604086850181905261094081860183610810565b9a87019a9450505090840190600101610914565b5090979650505050505050565b83815282602082015260606040820152600061098060608301846108fa565b95945050505050565b60006020828403121561099b57600080fd5b6109a482610640565b9392505050565b6020815260006109a460208301846108fa565b6000602082840312156109d057600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008251610a188184602087016107e0565b9190910192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000600019821415610a6557610a65610a22565b5060010190565b600082821015610a7e57610a7e610a22565b50039056fea26469706673582212207d7e2aa44f18af2935b0722dc2cf6d1679615dfbbe451813eb515c74e4abd84264736f6c63430008090033

ViewBlock

Copyright © 2022 Ashlar