Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- MultiSend
- Optimization enabled
- false
- Compiler version
- v0.7.6+commit.7338295f
- EVM Version
- default
- Verified at
- 2024-05-20T14:36:30.379322Z
contracts/libraries/MultiSend.sol
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.7.0 <0.9.0; /** * @title Multi Send - Allows to batch multiple transactions into one. * @author Nick Dodson - <[email protected]> * @author Gonçalo Sá - <[email protected]> * @author Stefan George - @Georgi87 * @author Richard Meissner - @rmeissner */ contract MultiSend { address private immutable MULTISEND_SINGLETON; constructor() { MULTISEND_SINGLETON = address(this); } /** * @dev Sends multiple transactions and reverts all if one fails. * @param transactions Encoded transactions. Each transaction is encoded as a packed bytes of * operation as a uint8 with 0 for a call or 1 for a delegatecall (=> 1 byte), * to as a address (=> 20 bytes), * value as a uint256 (=> 32 bytes), * data length as a uint256 (=> 32 bytes), * data as bytes. * see abi.encodePacked for more information on packed encoding * @notice This method is payable as delegatecalls keep the msg.value from the previous call * If the calling method (e.g. execTransaction) received ETH this would revert otherwise */ function multiSend(bytes memory transactions) public payable { require(address(this) != MULTISEND_SINGLETON, "MultiSend should only be called via delegatecall"); /* solhint-disable no-inline-assembly */ assembly { let length := mload(transactions) let i := 0x20 for { // Pre block is not used in "while mode" } lt(i, length) { // Post block is not used in "while mode" } { // First byte of the data is the operation. // We shift by 248 bits (256 - 8 [operation byte]) it right since mload will always load 32 bytes (a word). // This will also zero out unused data. let operation := shr(0xf8, mload(add(transactions, i))) // We offset the load address by 1 byte (operation byte) // We shift it right by 96 bits (256 - 160 [20 address bytes]) to right-align the data and zero out unused data. let to := shr(0x60, mload(add(transactions, add(i, 0x01)))) // Defaults `to` to `address(this)` if `address(0)` is provided. to := or(to, mul(iszero(to), address())) // We offset the load address by 21 byte (operation byte + 20 address bytes) let value := mload(add(transactions, add(i, 0x15))) // We offset the load address by 53 byte (operation byte + 20 address bytes + 32 value bytes) let dataLength := mload(add(transactions, add(i, 0x35))) // We offset the load address by 85 byte (operation byte + 20 address bytes + 32 value bytes + 32 data length bytes) let data := add(transactions, add(i, 0x55)) let success := 0 switch operation case 0 { success := call(gas(), to, value, data, dataLength, 0, 0) } case 1 { success := delegatecall(gas(), to, data, dataLength, 0, 0) } if eq(success, 0) { let errorLength := returndatasize() returndatacopy(0, 0, errorLength) revert(0, errorLength) } // Next entry starts at 85 byte + data length i := add(i, add(0x55, dataLength)) } } /* solhint-enable no-inline-assembly */ } }
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":false},"metadata":{"useLiteralContent":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"multiSend","inputs":[{"type":"bytes","name":"transactions","internalType":"bytes"}]}]
Contract Creation Code
0x60a060405234801561001057600080fd5b503073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b8152505060805160601c6102836100646000398060e052506102836000f3fe60806040526004361061001e5760003560e01c80638d80ff0a14610023575b600080fd5b6100dc6004803603602081101561003957600080fd5b810190808035906020019064010000000081111561005657600080fd5b82018360208201111561006857600080fd5b8035906020019184600183028401116401000000008311171561008a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506100de565b005b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415610183576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603081526020018061021e6030913960400191505060405180910390fd5b805160205b81811015610218578083015160f81c6001820184015160601c30811502811790506015830185015160358401860151605585018701600085600081146101d557600181146101e5576101f0565b6000808585888a5af191506101f0565b6000808585895af491505b506000811415610205573d806000803e806000fd5b8260550187019650505050505050610188565b50505056fe4d756c746953656e642073686f756c64206f6e6c792062652063616c6c6564207669612064656c656761746563616c6ca26469706673582212202b1a174e3e612379b1233b7fdae23e6d17a1abd37e10c1c93b99956600d02d8664736f6c63430007060033
Deployed ByteCode
0x60806040526004361061001e5760003560e01c80638d80ff0a14610023575b600080fd5b6100dc6004803603602081101561003957600080fd5b810190808035906020019064010000000081111561005657600080fd5b82018360208201111561006857600080fd5b8035906020019184600183028401116401000000008311171561008a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506100de565b005b7f00000000000000000000000072748e8aa838289e594e19675879f2d900730b5473ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415610183576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603081526020018061021e6030913960400191505060405180910390fd5b805160205b81811015610218578083015160f81c6001820184015160601c30811502811790506015830185015160358401860151605585018701600085600081146101d557600181146101e5576101f0565b6000808585888a5af191506101f0565b6000808585895af491505b506000811415610205573d806000803e806000fd5b8260550187019650505050505050610188565b50505056fe4d756c746953656e642073686f756c64206f6e6c792062652063616c6c6564207669612064656c656761746563616c6ca26469706673582212202b1a174e3e612379b1233b7fdae23e6d17a1abd37e10c1c93b99956600d02d8664736f6c63430007060033