MultiSender

Description:

Smart contract deployed on Ethereum with Factory features.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "remappings": []
  },
  "sources": {
    "multi-sender.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.0;\r
\r
/**\r
 * @title SafeERC20\r
 * @dev Wrappers around ERC20 operations that throw on failure (when the token\r
 * contract returns false). Tokens that return no value (and instead revert or\r
 * throw on failure) are also supported, non-reverting calls are assumed to be\r
 * successful.\r
 */\r
library SafeERC20 {\r
    /**\r
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\r
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\r
     */\r
    function safeTransferFrom(address token, address from, address to, uint256 value) internal {\r
        (bool success, bytes memory data) = token.call(\r
            abi.encodeWithSelector(0x23b872dd, from, to, value)\r
        );\r
        require(success && (data.length == 0 || abi.decode(data, (bool))), "Transfer failed");\r
    }\r
}\r
\r
interface IERC20 {\r
    function balanceOf(address account) external view returns (uint256);\r
    function allowance(address owner, address spender) external view returns (uint256);\r
}\r
\r
/**\r
 * @title MultiSender\r
 * @dev Universal multi-sender that works with ALL ERC20 tokens including USDT\r
 * @dev Uses OpenZeppelin's SafeERC20 pattern\r
 */\r
contract MultiSender {\r
    using SafeERC20 for address;\r
    \r
    address public owner;\r
    \r
    event MultiTransfer(\r
        address indexed sender,\r
        address indexed token,\r
        uint256 recipientCount\r
    );\r
    \r
    modifier onlyOwner() {\r
        require(msg.sender == owner, "Not owner");\r
        _;\r
    }\r
    \r
    constructor() {\r
        owner = msg.sender;\r
    }\r
    \r
    /**\r
     * @dev Send tokens to multiple recipients from user's balance\r
     * @param tokenAddress The ERC20 token contract address\r
     * @param recipients Array of recipient addresses\r
     * @param amounts Array of amounts to send to each recipient\r
     */\r
    function multiSend(\r
        address tokenAddress,\r
        address[] calldata recipients,\r
        uint256[] calldata amounts\r
    ) external {\r
        require(recipients.length > 0, "No recipients");\r
        require(recipients.length == amounts.length, "Length mismatch");\r
        require(recipients.length <= 200, "Too many recipients");\r
        \r
        IERC20 token = IERC20(tokenAddress);\r
        \r
        // Calculate total amount needed\r
        uint256 totalAmount = 0;\r
        for (uint256 i = 0; i < amounts.length; i++) {\r
            require(amounts[i] > 0, "Zero amount");\r
            require(recipients[i] != address(0), "Invalid recipient");\r
            totalAmount += amounts[i];\r
        }\r
        \r
        // Check user has approved enough tokens\r
        require(\r
            token.allowance(msg.sender, address(this)) >= totalAmount,\r
            "Insufficient allowance"\r
        );\r
        \r
        // Check user has enough balance\r
        require(\r
            token.balanceOf(msg.sender) >= totalAmount,\r
            "Insufficient balance"\r
        );\r
        \r
        // Transfer tokens using SafeERC20\r
        for (uint256 i = 0; i < recipients.length; i++) {\r
            tokenAddress.safeTransferFrom(msg.sender, recipients[i], amounts[i]);\r
        }\r
        \r
        emit MultiTransfer(msg.sender, tokenAddress, recipients.length);\r
    }\r
    \r
    /**\r
     * @dev Recover accidentally sent ERC20 tokens\r
     * @param tokenAddress The ERC20 token to recover\r
     * @param amount Amount to recover\r
     */\r
    function recoverERC20(address tokenAddress, uint256 amount) external onlyOwner {\r
        (bool success, bytes memory data) = tokenAddress.call(\r
            abi.encodeWithSelector(0xa9059cbb, owner, amount)\r
        );\r
        require(success && (data.length == 0 || abi.decode(data, (bool))), "Recovery failed");\r
    }\r
}"
    }
  }
}}

Tags:
Factory|addr:0x04cb18061560936b9bba572709ae4fec0b140c36|verified:true|block:23503335|tx:0xb857d2ed3c4c9a48d2eddb9b892252784b7e442a0d2952e19ee68fdf12324527|first_check:1759572212

Submitted on: 2025-10-04 12:03:32

Comments

Log in to comment.

No comments yet.