APE Price: $1.24 (-6.58%)

Contract Diff Checker

Contract Name:
BatchTransfer

Contract Source Code:

File 1 of 1 : BatchTransfer

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

contract BatchTransfer {
    address public owner;

    constructor() payable {
        owner = msg.sender;
    }

    event BatchTransferExecuted(address indexed sender, uint256 amount, address[] recipients);

    modifier onlyOwner() {
        require(msg.sender == owner, "Only the owner can call this function");
        _;
    }

    receive() external payable {}

    function deposit() external payable {}

    function withdrawAll() external onlyOwner {
        uint256 balance = address(this).balance;
        require(balance > 0, "Contract balance is zero");
        payable(owner).transfer(balance);
    }

    function batchTransfer(address[] calldata recipients, uint256 amountPerRecipient) external onlyOwner {
        uint256 totalAmount = recipients.length * amountPerRecipient;
        require(address(this).balance >= totalAmount, "Insufficient contract balance");

        for (uint256 i = 0; i < recipients.length; i++) {
            payable(recipients[i]).transfer(amountPerRecipient);
        }

        emit BatchTransferExecuted(msg.sender, amountPerRecipient, recipients);
    }

    function getBalance() external view returns (uint256) {
        return address(this).balance;
    }
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):