APE Price: $0.67 (-6.46%)

Contract Diff Checker

Contract Name:
MultiSend

Contract Source Code:

File 1 of 1 : MultiSend

// SPDX-License-Identifier: MIT
pragma solidity =0.8.26;

interface IERC20 {
    function transfer(address recipient, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
    function allowance(address owner, address spender) external view returns (uint256);
}

contract MultiSend {
    // Prevent contract from receiving native tokens directly
    receive() external payable {
        revert("Direct native transfers not allowed");
    }

    fallback() external payable {
        revert("Fallback function called");
    }

    // Function to send native tokens to multiple recipients
    function sendNative(address[] calldata recipients, uint256[] calldata amounts) external payable {
        require(recipients.length == amounts.length, "Mismatched inputs");

        uint256 totalAmount = 0;
        for (uint256 i = 0; i < amounts.length; i++) {
            totalAmount += amounts[i];
        }
        require(msg.value == totalAmount, "Incorrect native amount sent");

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

    // Function to send ERC-20 tokens from msg.sender to multiple recipients
    function sendTokens(IERC20 token, address[] calldata recipients, uint256[] calldata amounts) external {
        require(recipients.length == amounts.length, "Mismatched inputs");

        uint256 totalAmount = 0;
        for (uint256 i = 0; i < amounts.length; i++) {
            totalAmount += amounts[i];
        }

        // Check if msg.sender has approved enough tokens
        require(token.allowance(msg.sender, address(this)) >= totalAmount, "Insufficient allowance");

        for (uint256 i = 0; i < recipients.length; i++) {
            require(token.transferFrom(msg.sender, recipients[i], amounts[i]), "Transfer failed");
        }
    }
}

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

Context size (optional):