You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

创建TON钱包遇LITE_SERVER_UNKNOWN错误,求解决方案

解决TON钱包部署报错:LITE_SERVER_UNKNOWN: cannot apply external message to current state : Failed to unpack account state

问题根源

你代码里提前调用了const seqno = await wallet.methods.seqno().call();,但此时钱包还没部署,链上根本不存在这个账户,调用seqno会尝试读取一个未初始化的账户状态,导致解析失败,进而干扰后续的部署请求。

修复步骤

  • 移除提前获取seqno的代码:未部署的钱包没有链上状态,获取seqno完全没必要,反而会触发错误。
  • 确保账户未被初始化:如果这个地址之前已经尝试部署过但失败,建议换一个新的密钥对生成新地址重试。
  • 简化部署逻辑:直接调用deploy方法即可,TonWeb会自动处理新账户的seqno(默认是0)。

修改后的代码

const tonwebInstance = new TonWeb(
  new TonWeb.HttpProvider("https://toncenter.com/api/v2/jsonRPC", {
    apiKey: process.env.API_KEY,
  })
);

// 创建密钥对
const keyPair = nacl.sign.keyPair();
const publicKey = keyPair.publicKey;
const privateKey = keyPair.secretKey;

console.log("密钥对已创建");

// 生成钱包实例
const wallet = tonwebInstance.wallet.create({ publicKey });
console.log("钱包实例已创建");

// 获取钱包地址
const walletAddress = (await wallet.getAddress()).toString(true, true, true);
console.log("钱包地址: " + walletAddress);

// 直接部署钱包,无需提前获取seqno
await wallet.deploy(privateKey).send();
console.log("钱包部署成功");

额外验证建议

部署后可以查询账户状态确认是否成功:

// 部署后查询账户信息
const account = await tonwebInstance.provider.getAccount(walletAddress);
console.log("账户状态:", account);

内容的提问来源于stack exchange,提问作者esternit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 15:55:55