Contract Address Details

0x5213dF5e53c7526261cE006087E5db27F9C288Cf

Contract Name
BatchTransfer
Creator
0xdd6363–4b0ec3 at 0x234108–ced0b3
Balance
0 REI
Tokens
Fetching tokens...
Transactions
128 Transactions
Transfers
0 Transfers
Gas Used
392,050,862
Last Balance Update
34072131
Contract name:
BatchTransfer




Optimization enabled
false
Compiler version
v0.8.28+commit.7893614a




Verified at
2025-07-02T08:20:09.049977Z

contracts/BatchTransfer.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

contract BatchTransfer is ReentrancyGuard {
    function batchTransfer(
        address token,
        address[] calldata recipients,
        uint256[] calldata amounts
    ) external payable nonReentrant {
        require(
            recipients.length > 0,
            "Recipients length must be greater than 0"
        );
        require(
            recipients.length == amounts.length,
            "Recipients and amounts length mismatch"
        );

        uint256 totalAmount = sum(amounts);
        if (token == address(0)) {
            require(msg.value == totalAmount, "ETH transfer amount mismatch");
            for (uint256 i = 0; i < recipients.length; i++) {
                (bool sent, ) = payable(recipients[i]).call{value: amounts[i]}(
                    ""
                );
                require(sent, "Failed to send native token");
            }
        } else {
            uint256 allowance = IERC20(token).allowance(
                msg.sender,
                address(this)
            );
            require(allowance >= totalAmount, "ERC20 transfer not enough");
            IERC20 erc20Token = IERC20(token);
            for (uint256 i = 0; i < recipients.length; i++) {
                require(
                    erc20Token.transferFrom(
                        msg.sender,
                        recipients[i],
                        amounts[i]
                    ),
                    "Transfer failed"
                );
            }
        }
    }

    function sum(uint256[] calldata amounts) public pure returns (uint256) {
        uint256 total = 0;
        for (uint256 i = 0; i < amounts.length; i++) {
            total += amounts[i];
        }
        return total;
    }
}
        

@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
          

@openzeppelin/contracts/utils/ReentrancyGuard.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
          
>

Contract ABI

[{"type":"error","name":"ReentrancyGuardReentrantCall","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"batchTransfer","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address[]","name":"recipients","internalType":"address[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"sum","inputs":[{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]}]
              

Contract Creation Code

0x6080604052348015600f57600080fd5b506001600081905550610ccf806100276000396000f3fe6080604052600436106100295760003560e01c80630194db8e1461002e5780631239ec8c1461006b575b600080fd5b34801561003a57600080fd5b50610055600480360381019061005091906105b8565b610087565b604051610062919061061e565b60405180910390f35b610085600480360381019061008091906106ed565b6100db565b005b6000806000905060005b848490508110156100d0578484828181106100af576100ae610782565b5b90506020020135826100c191906107e0565b91508080600101915050610091565b508091505092915050565b6100e36104f9565b60008484905011610129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012090610897565b60405180910390fd5b818190508484905014610171576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016890610929565b60405180910390fd5b600061017d8383610087565b9050600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1603610303578034146101f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ec90610995565b60405180910390fd5b60005b858590508110156102fd57600086868381811061021857610217610782565b5b905060200201602081019061022d91906109b5565b73ffffffffffffffffffffffffffffffffffffffff1685858481811061025657610255610782565b5b9050602002013560405161026990610a13565b60006040518083038185875af1925050503d80600081146102a6576040519150601f19603f3d011682016040523d82523d6000602084013e6102ab565b606091505b50509050806102ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102e690610a74565b60405180910390fd5b5080806001019150506101f8565b506104e9565b60008673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b8152600401610340929190610aa3565b602060405180830381865afa15801561035d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103819190610af8565b9050818110156103c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103bd90610b71565b60405180910390fd5b600087905060005b878790508110156104e5578173ffffffffffffffffffffffffffffffffffffffff166323b872dd338a8a8581811061040957610408610782565b5b905060200201602081019061041e91906109b5565b89898681811061043157610430610782565b5b905060200201356040518463ffffffff1660e01b815260040161045693929190610b91565b6020604051808303816000875af1158015610475573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104999190610c00565b6104d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104cf90610c79565b60405180910390fd5b80806001019150506103ce565b5050505b506104f261053f565b5050505050565b600260005403610535576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600081905550565b6001600081905550565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261057857610577610553565b5b8235905067ffffffffffffffff81111561059557610594610558565b5b6020830191508360208202830111156105b1576105b061055d565b5b9250929050565b600080602083850312156105cf576105ce610549565b5b600083013567ffffffffffffffff8111156105ed576105ec61054e565b5b6105f985828601610562565b92509250509250929050565b6000819050919050565b61061881610605565b82525050565b6000602082019050610633600083018461060f565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061066482610639565b9050919050565b61067481610659565b811461067f57600080fd5b50565b6000813590506106918161066b565b92915050565b60008083601f8401126106ad576106ac610553565b5b8235905067ffffffffffffffff8111156106ca576106c9610558565b5b6020830191508360208202830111156106e6576106e561055d565b5b9250929050565b60008060008060006060868803121561070957610708610549565b5b600061071788828901610682565b955050602086013567ffffffffffffffff8111156107385761073761054e565b5b61074488828901610697565b9450945050604086013567ffffffffffffffff8111156107675761076661054e565b5b61077388828901610562565b92509250509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006107eb82610605565b91506107f683610605565b925082820190508082111561080e5761080d6107b1565b5b92915050565b600082825260208201905092915050565b7f526563697069656e7473206c656e677468206d7573742062652067726561746560008201527f72207468616e2030000000000000000000000000000000000000000000000000602082015250565b6000610881602883610814565b915061088c82610825565b604082019050919050565b600060208201905081810360008301526108b081610874565b9050919050565b7f526563697069656e747320616e6420616d6f756e7473206c656e677468206d6960008201527f736d617463680000000000000000000000000000000000000000000000000000602082015250565b6000610913602683610814565b915061091e826108b7565b604082019050919050565b6000602082019050818103600083015261094281610906565b9050919050565b7f455448207472616e7366657220616d6f756e74206d69736d6174636800000000600082015250565b600061097f601c83610814565b915061098a82610949565b602082019050919050565b600060208201905081810360008301526109ae81610972565b9050919050565b6000602082840312156109cb576109ca610549565b5b60006109d984828501610682565b91505092915050565b600081905092915050565b50565b60006109fd6000836109e2565b9150610a08826109ed565b600082019050919050565b6000610a1e826109f0565b9150819050919050565b7f4661696c656420746f2073656e64206e617469766520746f6b656e0000000000600082015250565b6000610a5e601b83610814565b9150610a6982610a28565b602082019050919050565b60006020820190508181036000830152610a8d81610a51565b9050919050565b610a9d81610659565b82525050565b6000604082019050610ab86000830185610a94565b610ac56020830184610a94565b9392505050565b610ad581610605565b8114610ae057600080fd5b50565b600081519050610af281610acc565b92915050565b600060208284031215610b0e57610b0d610549565b5b6000610b1c84828501610ae3565b91505092915050565b7f4552433230207472616e73666572206e6f7420656e6f75676800000000000000600082015250565b6000610b5b601983610814565b9150610b6682610b25565b602082019050919050565b60006020820190508181036000830152610b8a81610b4e565b9050919050565b6000606082019050610ba66000830186610a94565b610bb36020830185610a94565b610bc0604083018461060f565b949350505050565b60008115159050919050565b610bdd81610bc8565b8114610be857600080fd5b50565b600081519050610bfa81610bd4565b92915050565b600060208284031215610c1657610c15610549565b5b6000610c2484828501610beb565b91505092915050565b7f5472616e73666572206661696c65640000000000000000000000000000000000600082015250565b6000610c63600f83610814565b9150610c6e82610c2d565b602082019050919050565b60006020820190508181036000830152610c9281610c56565b905091905056fea264697066735822122091035e8d142bd622dc0a88c2cd1553514603e1662d8719dc44a72dec6fcda51f64736f6c634300081c0033

Deployed ByteCode

0x6080604052600436106100295760003560e01c80630194db8e1461002e5780631239ec8c1461006b575b600080fd5b34801561003a57600080fd5b50610055600480360381019061005091906105b8565b610087565b604051610062919061061e565b60405180910390f35b610085600480360381019061008091906106ed565b6100db565b005b6000806000905060005b848490508110156100d0578484828181106100af576100ae610782565b5b90506020020135826100c191906107e0565b91508080600101915050610091565b508091505092915050565b6100e36104f9565b60008484905011610129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012090610897565b60405180910390fd5b818190508484905014610171576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016890610929565b60405180910390fd5b600061017d8383610087565b9050600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1603610303578034146101f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ec90610995565b60405180910390fd5b60005b858590508110156102fd57600086868381811061021857610217610782565b5b905060200201602081019061022d91906109b5565b73ffffffffffffffffffffffffffffffffffffffff1685858481811061025657610255610782565b5b9050602002013560405161026990610a13565b60006040518083038185875af1925050503d80600081146102a6576040519150601f19603f3d011682016040523d82523d6000602084013e6102ab565b606091505b50509050806102ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102e690610a74565b60405180910390fd5b5080806001019150506101f8565b506104e9565b60008673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e33306040518363ffffffff1660e01b8152600401610340929190610aa3565b602060405180830381865afa15801561035d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103819190610af8565b9050818110156103c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103bd90610b71565b60405180910390fd5b600087905060005b878790508110156104e5578173ffffffffffffffffffffffffffffffffffffffff166323b872dd338a8a8581811061040957610408610782565b5b905060200201602081019061041e91906109b5565b89898681811061043157610430610782565b5b905060200201356040518463ffffffff1660e01b815260040161045693929190610b91565b6020604051808303816000875af1158015610475573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104999190610c00565b6104d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104cf90610c79565b60405180910390fd5b80806001019150506103ce565b5050505b506104f261053f565b5050505050565b600260005403610535576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600081905550565b6001600081905550565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f84011261057857610577610553565b5b8235905067ffffffffffffffff81111561059557610594610558565b5b6020830191508360208202830111156105b1576105b061055d565b5b9250929050565b600080602083850312156105cf576105ce610549565b5b600083013567ffffffffffffffff8111156105ed576105ec61054e565b5b6105f985828601610562565b92509250509250929050565b6000819050919050565b61061881610605565b82525050565b6000602082019050610633600083018461060f565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061066482610639565b9050919050565b61067481610659565b811461067f57600080fd5b50565b6000813590506106918161066b565b92915050565b60008083601f8401126106ad576106ac610553565b5b8235905067ffffffffffffffff8111156106ca576106c9610558565b5b6020830191508360208202830111156106e6576106e561055d565b5b9250929050565b60008060008060006060868803121561070957610708610549565b5b600061071788828901610682565b955050602086013567ffffffffffffffff8111156107385761073761054e565b5b61074488828901610697565b9450945050604086013567ffffffffffffffff8111156107675761076661054e565b5b61077388828901610562565b92509250509295509295909350565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006107eb82610605565b91506107f683610605565b925082820190508082111561080e5761080d6107b1565b5b92915050565b600082825260208201905092915050565b7f526563697069656e7473206c656e677468206d7573742062652067726561746560008201527f72207468616e2030000000000000000000000000000000000000000000000000602082015250565b6000610881602883610814565b915061088c82610825565b604082019050919050565b600060208201905081810360008301526108b081610874565b9050919050565b7f526563697069656e747320616e6420616d6f756e7473206c656e677468206d6960008201527f736d617463680000000000000000000000000000000000000000000000000000602082015250565b6000610913602683610814565b915061091e826108b7565b604082019050919050565b6000602082019050818103600083015261094281610906565b9050919050565b7f455448207472616e7366657220616d6f756e74206d69736d6174636800000000600082015250565b600061097f601c83610814565b915061098a82610949565b602082019050919050565b600060208201905081810360008301526109ae81610972565b9050919050565b6000602082840312156109cb576109ca610549565b5b60006109d984828501610682565b91505092915050565b600081905092915050565b50565b60006109fd6000836109e2565b9150610a08826109ed565b600082019050919050565b6000610a1e826109f0565b9150819050919050565b7f4661696c656420746f2073656e64206e617469766520746f6b656e0000000000600082015250565b6000610a5e601b83610814565b9150610a6982610a28565b602082019050919050565b60006020820190508181036000830152610a8d81610a51565b9050919050565b610a9d81610659565b82525050565b6000604082019050610ab86000830185610a94565b610ac56020830184610a94565b9392505050565b610ad581610605565b8114610ae057600080fd5b50565b600081519050610af281610acc565b92915050565b600060208284031215610b0e57610b0d610549565b5b6000610b1c84828501610ae3565b91505092915050565b7f4552433230207472616e73666572206e6f7420656e6f75676800000000000000600082015250565b6000610b5b601983610814565b9150610b6682610b25565b602082019050919050565b60006020820190508181036000830152610b8a81610b4e565b9050919050565b6000606082019050610ba66000830186610a94565b610bb36020830185610a94565b610bc0604083018461060f565b949350505050565b60008115159050919050565b610bdd81610bc8565b8114610be857600080fd5b50565b600081519050610bfa81610bd4565b92915050565b600060208284031215610c1657610c15610549565b5b6000610c2484828501610beb565b91505092915050565b7f5472616e73666572206661696c65640000000000000000000000000000000000600082015250565b6000610c63600f83610814565b9150610c6e82610c2d565b602082019050919050565b60006020820190508181036000830152610c9281610c56565b905091905056fea264697066735822122091035e8d142bd622dc0a88c2cd1553514603e1662d8719dc44a72dec6fcda51f64736f6c634300081c0033