账户
0x97...ab7e
0x97...aB7e

0x97...aB7e

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.7.6+commit.7338295f
语言
Solidity
合同源代码
文件 1 的 1:PresailDroplet.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.7.6;


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

library SafeMath {
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }
}

library Address {
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
}


contract PresailDroplet {
    using SafeMath for uint256;
    using Address for address payable;

    function presailDistribute(address payable[] calldata recipients, uint256[] calldata values) external payable {
        require(recipients.length == values.length, "Recipients and values must have the same length");
        for (uint256 i = 0; i < recipients.length; i = i.add(1)) {
            require(recipients[i] != address(0), "Recipient cannot be zero address");
            recipients[i].sendValue(values[i]);
        }
        uint256 balance = address(this).balance;
        if (balance > 0)
            msg.sender.sendValue(balance);
    }

    function presailDistributeToken(IERC20 token, address[] calldata recipients, uint256[] calldata values) external {
        require(recipients.length == values.length, "Recipients and values must have the same length");
        uint256 total = 0;
        for (uint256 i = 0; i < recipients.length; i = i.add(1))
            total = total.add(values[i]);
        require(token.transferFrom(msg.sender, address(this), total), "Token transferFrom failed");
        for (uint256 i = 0; i < recipients.length; i = i.add(1)) {
            require(recipients[i] != address(0), "Recipient cannot be zero address");
            require(token.transfer(recipients[i], values[i]), "Token transfer failed");
        }
    }

    function presailDistributeTokenSimple(IERC20 token, address[] calldata recipients, uint256[] calldata values) external {
        require(recipients.length == values.length, "Recipients and values must have the same length");
        for (uint256 i = 0; i < recipients.length; i = i.add(1)) {
            require(recipients[i] != address(0), "Recipient cannot be zero address");
            require(token.transferFrom(msg.sender, recipients[i], values[i]), "Token transfer failed");
        }
    }
}
设置
{
  "compilationTarget": {
    "PresailDroplet.sol": "PresailDroplet"
  },
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "remappings": []
}
ABI
[{"inputs":[{"internalType":"address payable[]","name":"recipients","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"presailDistribute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address[]","name":"recipients","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"presailDistributeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"address[]","name":"recipients","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"presailDistributeTokenSimple","outputs":[],"stateMutability":"nonpayable","type":"function"}]