金色财经

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 554|回复: 0

转账,家人们,有批量转 erc20 token 的工具嘛

[复制链接]

738

主题

844

帖子

4579

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
4579
QQ
发表于 2022-10-30 12:48:11 | 显示全部楼层 |阅读模式
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.10;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/access/Ownable.sol";


contract BatchTrans is Ownable {
    function batchToken(address token, address[] memory toAddrs, uint256[] memory amounts) public {
        require(Address.isContract(token), "BatchTrans: not a token");
        require(toAddrs.length > 0, "BatchTrans: to addresses is empty");
        require(toAddrs.length <= 100, "BatchTrans: to addresses more than 100");
        require(toAddrs.length == amounts.length, "BatchTrans: amounts error");

        for (uint256 i = 0 ; i < toAddrs.length ; i++) {
            Address.functionCall(token, abi.encodeWithSelector(0x23b872dd, _msgSender(), toAddrs[i], amounts[i]));
        }
    }

    function batchToken(address token, address[] memory toAddrs, uint256 amount) public {
        require(Address.isContract(token), "BatchTrans: not a token");
        require(toAddrs.length > 0, "BatchTrans: to addresses is empty");
        require(toAddrs.length <= 100, "BatchTrans: to addresses more than 100");

        for (uint256 i = 0 ; i < toAddrs.length ; i++) {
            Address.functionCall(token, abi.encodeWithSelector(0x23b872dd, _msgSender(), toAddrs[i], amount));
        }
    }
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|金色财经

GMT+8, 2026-2-9 03:02 , Processed in 0.016176 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表