GTokenTool全网最好的代币发行工具平台
当前位置:首页 >> 加密百科 >> TON 批量转账空投代币教程

TON 批量转账空投代币教程

admin 加密百科 16

TON最初是Telegram Open Network的缩写,由Telegram团队设计,旨在构建一个支持大规模用户的高性能区块链网络。2020年5月Telegram因监管压力退出后,项目由社区接管并更名为"The Open Network"。

准备工作

  1. 安装必要的工具

    • 安装 TON CLI

    • 安装 tonutils-go (适用于Go开发者)

    • 或使用 ton-http-api

    • 或使用第三方工具 GTokenTool

  2. 准备钱包

    • 确保你有足够的TON币支付交易费用

    • 准备一个包含所有接收地址的列表(CSV或TXT格式)

方法一:使用TON CLI批量转账

# 1. 准备转账列表文件 (transfers.json)
[
  {
    "address": "EQAB...",
    "amount": 1000000000, # 1个代币(假设代币有9位小数)
    "message": "Airdrop"
  },
  ...
]

# 2. 运行批量转账命令
toncli send --wallet your_wallet.json --transfers transfers.json --bounceable false

方法二:使用tonutils-go (Go代码示例)

package main

import (
	"context"
	"fmt"
	"github.com/xssnick/tonutils-go/address"
	"github.com/xssnick/tonutils-go/liteclient"
	"github.com/xssnick/tonutils-go/ton"
	"github.com/xssnick/tonutils-go/ton/wallet"
)

func main() {
	client := liteclient.NewConnectionPool()
	ctx := context.Background()
	
	// 连接到TON节点
	err := client.AddConnection(ctx, "135.181.140.212:13206", "K0t3+IWLOXHYMvMcrGZDPs+pn58a17LFbnXoQkKc2xw=")
	if err != nil {
		panic(err)
	}
	
	api := ton.NewAPIClient(client)
	
	// 加载钱包
	w, err := wallet.FromSeed(api, "your seed words", wallet.V4R2)
	if err != nil {
		panic(err)
	}
	
	// 准备接收地址列表
	recipients := []struct{
		Address string
		Amount  int64
	}{
		{"EQAB...", 1000000000},
		// 添加更多地址
	}
	
	// 创建批量转账
	var messages []*wallet.Message
	for _, r := range recipients {
		addr := address.MustParseAddr(r.Address)
		messages = append(messages, &wallet.Message{
			Mode: 1, // 支付转账费用
			InternalMessage: &tlb.InternalMessage{
				Bounce:  false,
				DstAddr: addr,
				Amount:  tlb.MustFromTON("0.05"), // 包含少量TON用于gas
				Body:    cell.BeginCell().MustStoreUInt(0, 32).MustStoreStringSnake("Airdrop").EndCell(),
			},
		})
	}
	
	// 发送交易
	block, err := api.CurrentMasterchainInfo(ctx)
	if err != nil {
		panic(err)
	}
	
	txHash, err := w.SendMany(ctx, &wallet.Message{
		Mode: 128+32, // 合并模式
		InternalMessage: &tlb.InternalMessage{
			Bounce: false,
			DstAddr: address.MustParseAddr("代币合约地址"),
			Amount:  tlb.MustFromTON("0.1"), // 足够支付所有转账
			Body:    cell.BeginCell().MustStoreUInt(0x595f07bc, 32).MustStoreUInt(0, 64).EndCell(),
		},
	}, messages...)
	
	if err != nil {
		panic(err)
	}
	
	fmt.Println("批量转账成功,交易哈希:", txHash)
}

方法三:使用TonAPI和JavaScript

const TonWeb = require('tonweb');
const {mnemonicToKeyPair} = require('tonweb-mnemonic');

async function bulkSend() {
  // 初始化
  const tonweb = new TonWeb(new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', {apiKey: 'YOUR_API_KEY'}));
  
  // 加载钱包
  const mnemonic = 'your seed phrase'.split(' ');
  const keyPair = await mnemonicToKeyPair(mnemonic);
  const WalletClass = tonweb.wallet.all['v4R2'];
  const wallet = new WalletClass(tonweb.provider, {publicKey: keyPair.publicKey});
  
  // 准备转账列表
  const transfers = [
    {address: 'EQAB...', amount: TonWeb.utils.toNano('1'), message: 'Airdrop'},
    // 更多转账...
  ];
  
  // 创建批量转账消息
  const seqno = await wallet.methods.seqno().call();
  const messages = transfers.map(transfer => ({
    to: transfer.address,
    amount: transfer.amount,
    payload: transfer.message
  }));
  
  // 发送交易
  const tx = await wallet.methods.transfer({
    secretKey: keyPair.secretKey,
    seqno: seqno,
    messages
  }).send();
  
  console.log('Transaction sent:', tx);
}

bulkSend().catch(console.error);

方法四:使用GTokenTool工具

ton批量转账工具:https://ton.gtokentool.com/send

Screenshot.png

填写信息

1 选择发送Ton主币,还是其他代币

2 选择发送其他代币,需要输入代币地址

3 填写收款地址和数量(每一行应包括地址和数量,逗号分隔)

例如 0QCLBoC--JdBVhFdhhH9_gjnlEi3xzmCAXKyLl1iOvZ5IeIG,10

注意事项

  1. Gas费用:确保钱包中有足够的TON支付交易费用

  2. 代币合约:如果是自定义代币,需要调用代币合约的转账方法

  3. 速率限制:避免短时间内发送过多交易

  4. 测试网络:先在测试网(TON Testnet)上测试批量转账

  5. 地址验证:确保所有接收地址都是有效的TON地址

优化建议

  1. 使用多签名钱包进行大规模空投

  2. 考虑使用TON Proxy或TON Storage进行离线签名

  3. 对于极大数量的转账,考虑分批次进行


如有不明白或者不清楚的地方,请加入官方电报群:https://t.me/GTokenTool

作者:GTokenTool一键发币平台

交流群:https://t.me/+Kz4u3xoDpFo3ZWY1

同类推荐