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

Solana测试网JS转账异常:交易成功却报反序列化填充缓冲区错误

Solana测试网转账异常求助

在使用JavaScript操作Solana测试网转账时遇到以下问题:

  • 控制台输出错误:Error: failed to send transaction: failed to deserialize solana_sdk:transaction::versioned:VersionedTransaction:io error: failed to fill whole buffer
  • 前端弹窗提示转账失败,但Solana Explorer显示交易已成功
  • 尝试多种方案仍未解决,恳请社区提供帮助

转账函数代码

const sendSolana = async () => {
  if (walletAddress && amountToSend && receiverWalletAddress) {
    const amount = BigInt(Math.floor(Number(amountToSend) * LAMPORTS_PER_SOL));
    const testnetConnection = new solanaWeb3.Connection(
      "https://api.testnet.solana.com",
    );
    const recentBlockhash = await testnetConnection.getLatestBlockhash();
    const senderPublicKey = new solanaWeb3.PublicKey(walletAddress);
    const receiverPublicKey = new solanaWeb3.PublicKey(receiverWalletAddress);
    const transaction = new solanaWeb3.Transaction({
      recentBlockhash: recentBlockhash.blockhash,
    });
    transaction.add(
      solanaWeb3.SystemProgram.transfer({
        fromPubkey: senderPublicKey,
        toPubkey: receiverPublicKey,
        lamports: amount,
      }),
    );
    transaction.sign(keyPair);
    try {
      const signature = await solanaWeb3.sendAndConfirmTransaction(
        testnetConnection,
        transaction,
        [keyPair],
      );
      console.log("SIGNATUREEEEE ", signature);
      const response = await testnetConnection.sendRawTransaction(signature);
      console.log(response);
      if (response.txid) {
        alert("Solana sent successfully!");
      } else {
        alert("Failed to send Solana!");
      }
    } catch (error) {
      console.error("Error sending Solana:", error);
      alert("Failed to send Solana: " + error.message);
    }
  } else {
    alert("Insufficient data!");
  }
};

若您遇过类似问题或有相关见解,欢迎分享经验,感谢支持!


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 17:02:59