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

Node.js中Web3 BEP20转账交易不上链异常问题咨询

问题:BSC测试网BEP20转账交易无法上链,仅返回哈希无回执
  • 在BSC测试网使用Node.js的Web3库发起BEP20代币转账,调用合约发送交易后仅返回交易哈希,无法获取交易回执,链上也查询不到该交易记录
  • 再次发起交易时出现错误:INTERNAL_ERROR: could not replace existing tx
  • 修改nonce后虽能返回新的交易哈希,但链上仍无对应交易,且发起账户未扣除任何资金
  • 补充:调用web3.eth.getTransaction(txHash)可以获取到交易信息,但该交易始终无法上链

相关代码

const contract = new web3.eth.Contract(abiJson, contract_address, { gasPrice: "51067" });

await contract.methods.transfer(receiver_address, 10000000).send({
      from: sender_address,
      gas: 21596,
      nonce: 0,
    })
    .on("transactionHash", function (hash) {
      console.log(hash);
    })
    .on("confirmation", function (confirmationNumber, receipt) {
      console.log(confirmationNumber, receipt);
    })
    .on("receipt", function (receipt) {
      // receipt example
      console.log(receipt);
    })
    .on("error", function (error, receipt) {
      console.log(error, receipt);
    })

返回的交易哈希示例

0x0ac1c9e3ad108068f953299c82343057d2e739fab9801e897b25d53170fe3ff0

调用web3.eth.getTransaction(txHash)返回结果

{
  blockHash: null,
  blockNumber: null,
  from: '0x5de622df348974877Cf7108785f67e09b97785Fc',
  gas: 21596,
  gasPrice: '51067',
  hash: '0x0ac1c9e3ad108068f953299c82343057d2e739fab9801e897b25d53170fe3ff0',
  input: '0xa9059cbb000000000000000000000000ff3b0833aab74477d5efa1665632709cc8e2e0f800000000000000000000000000000000000000000000000000000000000186a0',
  nonce: 4,
  to: '0x337610d27c682E347C9cD60BD4b3b107C9d34dDd',
  transactionIndex: null,
  value: '0',
  type: 0,
  v: '0xe5',
  r: '0x2a0c5365fff32a2314ab1aee0847aa7202b5cdd8f5e070df162e47b7e9ed65a5',
  s: '0x4415513033acb12a484498252b8247d8f33bbb80d5093f77df4d2c515744dde7'
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 09:57:19