@anywalletkit/wallet-ton

中文文档
0.7.0发布于 2026/11/03Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2168

任何钱包的TON钱包:SLIP-10 m/44'/607'/i"在钱包ContactV5R1,TON和喷气管的转账,toncenter失效.

中文使用文档
文档目录8 节
  1. 安装
  2. 每个发送
  3. 签名人
  4. 信件和 TON 连接
  5. 说明
  6. 缓冲
  7. 原生反应
  8. 活动历史

@anywalletkit/wallet-ton (英语)

npm

TON 账户 m/44'/607'/i' (SLIP-10 ed25519)关于钱包的V5R1 — s bIP-39 短语的信托钱包和Ledger用法 黄金向量在 @anywalletkit/conformance。运行时间依赖性 : @ton/core, (中文(简体) ), @ton/crypto, (中文(简体) ), buffer (无) @ton/ton: V5R1 合同和指针 在此执行客户端, 检查字节换字节 @ton/ton (在测试中).

安装

npm install @anywalletkit/wallet-ton
# or: pnpm add @anywalletkit/wallet-ton  ·  yarn add @anywalletkit/wallet-ton

时间: @anywalletkit/wallet-ton (英语)发表于 发布工作流程 与出处.

import WalletManagerTon from '@anywalletkit/wallet-ton'

const wallet = new WalletManagerTon(seedPhrase, {
  tonClient: [{ url: 'https://toncenter.com/api/v2/jsonRPC', secretKey }],   // fails over in order
  // emulate: {kind: 'tonapi'} is the default (tonapi.io/v2/wallet/emulate, then /traces/emulate);
  // {kind: 'toncenter-v3', url} switches the emulator, false = estimateFee only.
  tonApiKey,                                                                  // optional: Bearer key for tonapi
})
const account = await wallet.getAccount(0)

account.describe({ to: 'UQ…', value: 100_000_000n, body: 'thanks' })         // offline: kind, items, warnings
await account.simulateTransaction({ to: 'UQ…', value: 100_000_000n })         // fees + emulation verdict + risk (what leaves the wallet)
await account.transfer({ recipient: 'UQ…', amount: 100_000_000n })            // 0.1 TON
await account.transfer({ token: USDT_MASTER, recipient: 'UQ…', amount: 1_000_000n, forwardPayload: 'hi' })
await account.sendTransaction([                                               // several messages, ONE external
  { to: 'EQ…', value: 50_000_000n, bodyBoc, stateInit },                      // e.g. an Omniston escrow deploy
  { to: 'UQ…', value: 1n },
])
const receipt = await account.getTransactionReceipt(hash)                     // hash = body hash, via toncenter v3
wallet.dispose()

// Tonkeeper-style 24-word TON mnemonic (not BIP-39): one account, same surface.
const tk = await WalletManagerTon.fromTonMnemonic(words, { tonClient })

每个发送

  1. 硬检查,在任何网络呼叫之前:值 > 0,仅工作链 0/-1, 友好地址网络旗帜匹配 config.network, (中文(简体) ), valid_until =: 现在 + validUntilSeconds (默认60,最大600).
  2. Fresh sexno (从未在发送中缓存).
  3. 在零签名的机体上飞行:指针 estimateFee (费用上限) 和微量仿真——默认的托纳皮(tonapi)POST /v2/wallet/emulate, (中文(简体) ), 倒计时 /v2/traces/emulate),或指向下方 emulateTrace 结束点通过 emulate: {kind: 'toncenter-v3', url}非零计算退出, 中止交易、失败动作阶段或失败 首先跳过 内部消息( 操作会反弹) 扔出 SimulationError 签署前; 追踪中更深的失败是 warnings托纳皮的 risk 返回为 risk。带有128发送模式的信息(全文) 或32个(一旦空出即被销毁的账户) UnsafeTransactionError('drain') 除非 allowDrainingTransactions ——已检查 任何模仿之前,当地, 预建的尸体太, 和再次在托纳皮的风险. describeTransaction 显示每个信件的 mode。 。 。 . emulate: false 仅保留 estimateFee· ; simulate: false 完全跳过飞行前(不是模式检查). 喷气机传输的接收和响应目的地得到同样的网络 (只测试旗)和工作链检查作为本土转移. 没有明确答案的广播(没有回应、超时、非JSON机构) 掷出 BroadcastUnknownError (单位:千美元)maybeSent, (中文(简体) ), hash =身体散:不要签名 一个节点 ok: false 保留a NetworkError。 。 。 . 习惯 TonRpc 应标明拒绝 answered: true (单位:千美元)isAnsweredRefusal) (中文(简体) ).
  4. 高贵的德25519 在身体散列上; 32字节种子是唯一的关键材料 财务报告和审定财务报表 dispose() 将其零化.
  5. sendBoc 外部(当钱包未部署时,为国家Init).

签名人

账户里没有钥匙 每一个签名都是 signer.sign(bytes, {scheme: 'ed25519', context}) 电话 : ton-external 在V5R1 签名单元格的散列上(飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行后,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行前,飞行中,飞行后,飞行中,飞行后,飞行中,飞行后,飞行中,飞行后,飞行后,飞行后,飞行中,飞行中,飞行中,飞行后,飞行中,飞行中,飞行后,飞行后,飞行后,飞行后,飞行中,飞行后,飞行中,飞行后,飞行中,飞行中,飞行中,飞行后,飞行中,飞行中 零号机身, ton-message 超过原始消息字节( r)sign(), (中文(简体) ), ton-proof 编号 : ton-sign-data 超过TON连接文摘(signTonProof, (中文(简体) ), signTonConnectData) (中文(简体) ). 种子钱包得到一个 LocalSigner; 硬件钱包、 MPC 节点或后端被包裹 externalSigner() 从 @anywalletkit/core数字 :

const signer = externalSigner({ curve: 'ed25519', publicKey, sign: (payload, { context }) => device.sign(payload) })
const manager = new WalletManagerTon(signer, { tonClient })
const account = await manager.getAccount() // path 'external'; other indexes throw

一个衍生 SeedSigner 时间 m/44'/607' 产量 getAccount(i) 子; 树叶标志器(包括 fromTonMnemonic)是一个账户. WalletAccountTon.fromPrivateKey(priv, pub, path) 留着 生键形状 呼叫者自生自出.

信件和 TON 连接

sign(message) 是原始字节上的十六进制 ed25519 签名。 32字节信息——字节或一个 编码为 32 字节的字符串—— 拒绝使用 MessageIsTransactionError: 钱包合同 检查在签名单元格的32字节散列上的转移签名,所以32个生字节可能是一个 转移。 TON Connect有自己的方法,它从请求和请求中构建摘要 账户自己的地址( 0xffff qq"ton- connection...", 绝不是一个单元格散列):

const proof = await account.signTonProof({ domain: 'app.example', timestamp, payload })  // the `proof` of a ton_proof reply
const reply = await account.signTonConnectData({ domain: 'app.example', timestamp, payload: { type: 'text', text } }) // signData (text | binary)

domain 钱包显示的请求来自主机, 而不是 DApp 自己的索赔 .

说明

describeTransaction(tx) 编号 : account.describe(tx) 解码 TON 传输(文本 注释),喷气式飞机转移(0x0f8a7ea5: 数量、目的地、前进 数额/载荷、自定义有效载荷)和合同电话,也来自预建的V5R1 身体,带有警告: zero-value, (中文(简体) ), non-bounceable-contract-call, (中文(简体) ), unknown-body, (中文(简体) ), large-forward-amount, (中文(简体) ), testnet-address 编号 : mainnet-address, (中文(简体) ), exotic-workchain。 。 。 .

缓冲

导入包时安装 buffer 多填充为 globalThis.Buffer 若为 无@ton/core 需要全球网络)。 节点和已经设置的应用程序 它,是未触及.

原生反应

@ton/crypto-primitives 决定: react-native 以Metro为基础 需求 expo-crypto (随机字节) react-native-fast-pbkdf2 为TON-兆位导入。 安装 expo-crypto 在应用程序中(Expo项目已经拥有). BIP- 39 钱包通过贵族签名 ed25519 两者都不需要.

活动历史

createTonHistory 是链子 HistorySource (单位:千美元)@anywalletkit/core:tonapi帐号事件起先,toncenter v3作为减少倒计时.

import { createTonHistory } from '@anywalletkit/wallet-ton/history'

const history = createTonHistory({ apiKey: process.env.TONAPI_KEY })
const page = await history.listActivity('UQCbXJ1-Hd_CyyAt3TNgircduNIn5QH5dj1_LBNz__y4fQaq', { limit: 25 })
const older = await history.listActivity(address, { cursor: page.cursor })
const one = await history.getTransaction(page.items[0].hash, address)
history.explorerTxUrl(one.hash) // https://tonviewer.com/transaction/…
选项默认说明
tonapiUrlhttps://tonapi.io (单位:千美元)testnet.tonapi.io(中文(简体) )null 禁用 tonapi .
apiKey无tonapi Bearer 密钥 。 无键 tonapi 允许 ~1 请求/s .
toncenterUrlhttps://toncenter.com (单位:千美元)testnet.toncenter.com(中文(简体) )v3倒计时; null 关闭它.
toncenterApiKey无X-API-Key。 。 。 .
networkmainnetton:-239 编号 : ton:-3。 。 。 .
rateLimit1 rps 无密钥, 10 有密钥tonapi 请求每秒( 中点:1 无密钥, 10 有密钥) .
fetch, (中文(简体) ), timeoutMs全球,15 000

托纳皮 (单位:千美元)GET /v2/accounts/{a}/events?limit=&before_lt=, (中文(简体) ), GET /v2/accounts/{a}/events/{id}: 1个事件=1个跟踪,有被键入的动作. TonTransfer, (中文(简体) ), JettonTransfer, (中文(简体) ), JettonMint, (中文(简体) ), JettonBurn, (中文(简体) ), JettonSwap (TON / 喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷雾式喷气式喷气式喷雾式喷雾式喷雾式喷气雾式喷雾式喷气气雾式喷气管), SmartContractExec (单位:千美元)ton_attached, (中文(简体) ), DepositStake 编号 : WithdrawStake (摇篮子), Subscribe, (中文(简体) ), NftPurchase,选举成为转移;喷气式飞机转移将主人作为 token, (中文(简体) ), standard: 'jetton', (中文(简体) ), symbol 财务报告和审定财务报表 decimals 从动作的喷出物。 第一个合同级行动是 call数字 : SmartContractExec → to =合同,hex op in data,名为 op in method· ; JettonSwap • 路由器/ swap; 发送到合同的喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气式喷气管式喷气式喷气气管 jetton_transfer 与托纳皮的操作 Call: 0x… 注释; DepositStake * 现金池/ stake, (中文(简体) ), WithdrawStakeRequest * 现金池/ unstake, (中文(简体) ), WithdrawStake * 现金池/ withdraw_stake. tonapi没有写出一个未取出请求的池上烧伤,所以对于这些事件,来源会获取 /v2/events/{id} 一次,转帐 value_flow 将喷气三角洲转换为转移raw.valueFlow) (中文(简体) ). from 是第一个行动的发起者, nativeValue 它发送的TON, fee =: -extra (tonapi的"账户损失超出其行动",所以它包括了动作未显示的远期费用), status =: pending 时 in_progress, (中文(简体) ), failed 当每次行动失败时, block =该事件 lt, (中文(简体) ), hash = 事件 id (痕量根; tonapi 解决任何交易散列的痕量). is_scam 标出事件 scam: true (另见 raw.scam) (中文(简体) ). 地址保持原样( N)0:…, 小写),作为tonapi返回它们.

toncenter v3 (中文(简体) ) (单位:千美元)GET /api/v3/transactions?account=&limit=&sort=desc&end_lt=:账户只有自己的交易. 一个外部消息( 钱包已激活) 将其输出的消息映射到 TON 传输中, 以及第一个操作代码到 call (单位:千美元)data =: opcode, (中文(简体) ), method =: decoded_opcode; 来函显示其价值和操作。 这里看不到喷气管, fee =: total_fees, (中文(简体) ), hash = 交易散列为六分之一.

咒语. 基础64 JSON { v: 1, b: 'tonapi' | 'toncenter', lt }: 独家 lt 上方绑定( o)before_lt 对于托纳皮, end_lt = lt − 1 用于Toncenter). 一个后端的光标会恢复到另一个后端;它发布的后端会先尝试. since 被应用客户端和结束页.

装入 test/fixtures/history/ 2026年10月14日从 tonapi.io 财务报告和审定财务报表 toncenter.com 测试钱包的(无键):一个事件页,Tonstakers的账户范围事件(Tonstakers sicks / unstake request / payout)和Omniston STON.fi的互换和代管命令(与这些模块的活动固定装置相同的交易), 与 value_flow 为未取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取取. test/history.test.ts 检查 Tonstakers 和 Omniston 模块描述此来源所构建的行(stake, (中文(简体) ), unstake, (中文(简体) ), claim, (中文(简体) ), swap, (中文(简体) ), bridge) (中文(简体) ). 说明: @anywalletkit/protocol-swap2-core是因为 netTransfers 比较地址逐字记录,所以 DescribeActivityContext.own 必须包含原始 0:… omniston 的钱包形式(Tonstakers 普通化).

版本与发布记录

@anywalletkit/wallet-ton 共发布 12 个版本,首次发布于 2026/10/25;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/11/034 天前
0.5.02026/10/309 天前
0.4.02026/10/2810 天前
0.3.12026/10/2811 天前
0.3.02026/10/2711 天前
0.2.52026/10/2612 天前

关于 @anywalletkit/wallet-ton 的常见问题

@anywalletkit/wallet-ton 是什么?

任何钱包的TON钱包:SLIP-10 m/44'/607'/i"在钱包ContactV5R1,TON和喷气管的转账,toncenter失效.

如何安装 @anywalletkit/wallet-ton?

在项目目录运行 npm install @anywalletkit/wallet-ton,或使用 pnpm add / yarn add / bun add。

@anywalletkit/wallet-ton 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anywalletkit/wallet-ton 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anywalletkit/wallet-ton 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anywalletkit/wallet-ton 可以商用吗?

@anywalletkit/wallet-ton 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anywalletkit/wallet-ton 的下载量有多少?

根据 npm 官方下载统计,@anywalletkit/wallet-ton 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,168 次,日均约 72 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anywalletkit/wallet-ton 还在维护吗?

最新版本 0.7.0 发布于 2026/11/03(4 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。