TON 批量转账空投代币教程

  • 想样
  • 发布于 15小时前
  • 阅读 5

TON最初是TelegramOpenNetwork的缩写,由Telegram团队设计,旨在构建一个支持大规模用户的高性能区块链网络。2020年5月Telegram因监管压力退出后,项目由社区接管并更名为"TheOpenNetwork"。准备工作安装必要的工具:安装TONCL

<!--StartFragment-->

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

<!--EndFragment-->

  • 原创
  • 学分: 0
  • 分类: TON
  • 标签:
点赞 0
收藏 0
分享

0 条评论

请先 登录 后评论
想样
想样
0x6a37...B276
江湖只有他的大名,没有他的介绍。