- Contract name:
- Multisender
- Optimization enabled
- false
- Compiler version
- v0.8.10+commit.fc410830
- EVM Version
- default
- Verified at
- 2022-11-23 13:55:10.372950Z
Contract source code
// File: @uniswap/lib/contracts/libraries/TransferHelper.sol
pragma solidity >=0.6.0;
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
// File: Multisender.sol
pragma solidity 0.8.10;
contract Multisender is ReentrancyGuard {
modifier checkListLegnths(uint256 receiversLength, uint256 amountsLength) {
require(receiversLength > 0, "Multisender: No addresses to send");
require(
receiversLength == amountsLength,
"Multisender: Arrays lengths must be equal"
);
_;
}
function multisendToken(
IERC20 tokenAddress,
address[] calldata receivers,
uint256[] calldata amounts
)
external
checkListLegnths(receivers.length, amounts.length)
nonReentrant
{
for (uint256 i = 0; i < receivers.length; i++) {
TransferHelper.safeTransferFrom(
address(tokenAddress),
msg.sender,
receivers[i],
amounts[i]
);
}
}
function multisendETH(
address payable[] calldata receivers,
uint256[] calldata amounts
)
external
payable
checkListLegnths(receivers.length, amounts.length)
nonReentrant
{
for (uint256 i = 0; i < receivers.length; i++) {
TransferHelper.safeTransferETH(
receivers[i],
amounts[i]
);
}
}
}
Contract ABI
[{"type":"function","stateMutability":"payable","outputs":[],"name":"multisendETH","inputs":[{"type":"address[]","name":"receivers","internalType":"address payable[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"multisendToken","inputs":[{"type":"address","name":"tokenAddress","internalType":"contract IERC20"},{"type":"address[]","name":"receivers","internalType":"address[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"}]}]
Deployed ByteCode
0x6080604052600436106100295760003560e01c80630b66f3f51461002e578063bfbe346a14610057575b600080fd5b34801561003a57600080fd5b5061005560048036038101906100509190610660565b610073565b005b610071600480360381019061006c919061074b565b610187565b005b8383905082829050600082116100be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100b59061084f565b60405180910390fd5b808214610100576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f7906108e1565b60405180910390fd5b610108610298565b60005b8686905081101561017557610162883389898581811061012e5761012d610901565b5b9050602002016020810190610143919061095c565b88888681811061015657610155610901565b5b905060200201356102e8565b808061016d906109c2565b91505061010b565b5061017e610421565b50505050505050565b8383905082829050600082116101d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101c99061084f565b60405180910390fd5b808214610214576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161020b906108e1565b60405180910390fd5b61021c610298565b60005b86869050811015610287576102748787838181106102405761023f610901565b5b90506020020160208101906102559190610a49565b86868481811061026857610267610901565b5b9050602002013561042b565b808061027f906109c2565b91505061021f565b50610290610421565b505050505050565b600260005414156102de576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102d590610ac2565b60405180910390fd5b6002600081905550565b6000808573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161031c93929190610b00565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161036a9190610bb1565b6000604051808303816000865af19150503d80600081146103a7576040519150601f19603f3d011682016040523d82523d6000602084013e6103ac565b606091505b50915091508180156103da57506000815114806103d95750808060200190518101906103d89190610c00565b5b5b610419576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161041090610c9f565b60405180910390fd5b505050505050565b6001600081905550565b60008273ffffffffffffffffffffffffffffffffffffffff1682600067ffffffffffffffff8111156104605761045f610cbf565b5b6040519080825280601f01601f1916602001820160405280156104925781602001600182028036833780820191505090505b506040516104a09190610bb1565b60006040518083038185875af1925050503d80600081146104dd576040519150601f19603f3d011682016040523d82523d6000602084013e6104e2565b606091505b5050905080610526576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051d90610d60565b60405180910390fd5b505050565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061056082610535565b9050919050565b600061057282610555565b9050919050565b61058281610567565b811461058d57600080fd5b50565b60008135905061059f81610579565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126105ca576105c96105a5565b5b8235905067ffffffffffffffff8111156105e7576105e66105aa565b5b602083019150836020820283011115610603576106026105af565b5b9250929050565b60008083601f8401126106205761061f6105a5565b5b8235905067ffffffffffffffff81111561063d5761063c6105aa565b5b602083019150836020820283011115610659576106586105af565b5b9250929050565b60008060008060006060868803121561067c5761067b61052b565b5b600061068a88828901610590565b955050602086013567ffffffffffffffff8111156106ab576106aa610530565b5b6106b7888289016105b4565b9450945050604086013567ffffffffffffffff8111156106da576106d9610530565b5b6106e68882890161060a565b92509250509295509295909350565b60008083601f84011261070b5761070a6105a5565b5b8235905067ffffffffffffffff811115610728576107276105aa565b5b602083019150836020820283011115610744576107436105af565b5b9250929050565b600080600080604085870312156107655761076461052b565b5b600085013567ffffffffffffffff81111561078357610782610530565b5b61078f878288016106f5565b9450945050602085013567ffffffffffffffff8111156107b2576107b1610530565b5b6107be8782880161060a565b925092505092959194509250565b600082825260208201905092915050565b7f4d756c746973656e6465723a204e6f2061646472657373657320746f2073656e60008201527f6400000000000000000000000000000000000000000000000000000000000000602082015250565b60006108396021836107cc565b9150610844826107dd565b604082019050919050565b600060208201905081810360008301526108688161082c565b9050919050565b7f4d756c746973656e6465723a20417272617973206c656e67746873206d75737460008201527f20626520657175616c0000000000000000000000000000000000000000000000602082015250565b60006108cb6029836107cc565b91506108d68261086f565b604082019050919050565b600060208201905081810360008301526108fa816108be565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b61093981610555565b811461094457600080fd5b50565b60008135905061095681610930565b92915050565b6000602082840312156109725761097161052b565b5b600061098084828501610947565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000819050919050565b60006109cd826109b8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610a00576109ff610989565b5b600182019050919050565b6000610a1682610535565b9050919050565b610a2681610a0b565b8114610a3157600080fd5b50565b600081359050610a4381610a1d565b92915050565b600060208284031215610a5f57610a5e61052b565b5b6000610a6d84828501610a34565b91505092915050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b6000610aac601f836107cc565b9150610ab782610a76565b602082019050919050565b60006020820190508181036000830152610adb81610a9f565b9050919050565b610aeb81610555565b82525050565b610afa816109b8565b82525050565b6000606082019050610b156000830186610ae2565b610b226020830185610ae2565b610b2f6040830184610af1565b949350505050565b600081519050919050565b600081905092915050565b60005b83811015610b6b578082015181840152602081019050610b50565b83811115610b7a576000848401525b50505050565b6000610b8b82610b37565b610b958185610b42565b9350610ba5818560208601610b4d565b80840191505092915050565b6000610bbd8284610b80565b915081905092915050565b60008115159050919050565b610bdd81610bc8565b8114610be857600080fd5b50565b600081519050610bfa81610bd4565b92915050565b600060208284031215610c1657610c1561052b565b5b6000610c2484828501610beb565b91505092915050565b7f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260008201527f616e7366657246726f6d206661696c6564000000000000000000000000000000602082015250565b6000610c896031836107cc565b9150610c9482610c2d565b604082019050919050565b60006020820190508181036000830152610cb881610c7c565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60008201527f20455448207472616e73666572206661696c6564000000000000000000000000602082015250565b6000610d4a6034836107cc565b9150610d5582610cee565b604082019050919050565b60006020820190508181036000830152610d7981610d3d565b905091905056fea2646970667358221220c7bb250f5cbac4e4894cc8b193bbd7f6cf11fbfbc0f8dda39ca590041bb3e56064736f6c634300080a0033