TON最初是TelegramOpenNetwork的缩写,由Telegram团队设计,旨在构建一个支持大规模用户的高性能区块链网络。2020年5月Telegram因监管压力退出后,项目由社区接管并更名为"TheOpenNetwork"。准备工作安装必要的工具:安装TONCL
<!--StartFragment-->
TON最初是Telegram Open Network的缩写,由Telegram团队设计,旨在构建一个支持大规模用户的高性能区块链网络。2020年5月Telegram因监管压力退出后,项目由社区接管并更名为"The Open Network"。
# 1. 准备转账列表文件 (transfers.json)
[
{
"address": "EQAB...",
"amount": 1000000000, # 1个代币(假设代币有9位小数)
"message": "Airdrop"
},
...
]
# 2. 运行批量转账命令
toncli send --wallet your_wallet.json --transfers transfers.json --bounceable false
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)
}
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);
ton批量转账工具:<https://ton.gtokentool.com/send>
<!--EndFragment-->
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!