BatchAirdrop

0x21c9dd37c8f4f05e929827d18c2e796bb9152775

Verification
Verified
v0.8.10+commit.fc410830
Type
Contract
1,082 bytes
ABI entries
2
0 read · 2 write
License
none

Contract information

Address
0x21c9dd37c8f4f05e929827d18c2e796bb9152775
Chain
Robinhood Chain (4663)
Compiler
v0.8.10+commit.fc410830
Optimization
Enabled
Creation tx
0x00f4413628…c3fb2d6bfc

Token

Not a token

This contract does not expose ERC-20 metadata.

Read contract (0)

No read functions

The ABI is unavailable or exposes no view functions.

ABI

[
  {
    "inputs": [
      {
        "internalType": "contract IERC20",
        "name": "token",
        "type": "address"
      },
      {
        "internalType": "address[]",
        "name": "recipients",
        "type": "address[]"
      },
      {
        "internalType": "uint256",
        "name": "amount",
        "type": "uint256"
      }
    ],
    "name": "airdrop",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "contract IERC20",
        "name": "token",
        "type": "address"
      },
      {
        "internalType": "address[]",
        "name": "recipients",
        "type": "address[]"
      },
      {
        "internalType": "uint256[]",
        "name": "amounts",
        "type": "uint256[]"
      }
    ],
    "name": "airdropVariable",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

Source code

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

interface IERC20 {
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

/// @title BatchAirdrop
/// @notice Sends tokens from `msg.sender` to many recipients in one tx using
///         `transferFrom`. Tokens move sender -> recipient DIRECTLY (a single
///         hop), which is critical for fee-on-transfer tokens like MINI CASH CAT:
///         a classic "pool then distribute" disperse would charge the transfer
///         fee twice. This contract never holds the token.
///
///         Before calling, `msg.sender` must `approve(thisContract, total)` on
///         the token, where total = amount * recipients.length (or the sum of
///         `amounts`). Because the token is fee-on-transfer, `amount` here is the
///         GROSS (pre-fee) amount; each recipient nets amount * (1 - fee).
contract BatchAirdrop {
    /// @notice Send the same gross `amount` to each recipient.
    function airdrop(
        IERC20 token,
        address[] calldata recipients,
        uint256 amount
    ) external {
        uint256 n = recipients.length;
        for (uint256 i = 0; i < n; ) {
            require(
                token.transferFrom(msg.sender, recipients[i], amount),
                "transferFrom failed"
            );
            unchecked { ++i; }
        }
    }

    /// @notice Send a per-recipient gross `amounts[i]` to each recipient.
    function airdropVariable(
        IERC20 token,
        address[] calldata recipients,
        uint256[] calldata amounts
    ) external {
        require(recipients.length == amounts.length, "length mismatch");
        uint256 n = recipients.length;
        for (uint256 i = 0; i < n; ) {
            require(
                token.transferFrom(msg.sender, recipients[i], amounts[i]),
                "transferFrom failed"
            );
            unchecked { ++i; }
        }
    }
}
Chain explorer6094msChain node79ms