[英]Ethers.js : "NONCE EXPIRED" when replacing transaction
当我尝试用相同的 nonce 和更高的 gas 费用替换交易时,我遇到了这个问题。 例如,我使用来自 DEX 的交换 function:
const tx1 = await contract.swapExactTokensForTokens( amountIn, amountOutMin, [TokenIn, TokenOut], AddressTo, deadline, {'gasPrice': gasPrice, 'gasLimit': gasLimit})
然后我尝试用 tx1 的随机数替换交易:
const tx2 = await contract.swapExactTokensForTokens( amountIn, amountOutMin, [TokenIn, TokenOut], AddressTo, deadline, {'gasPrice': gasPrice+1*10**9, 'gasLimit': gasLimit, 'nonce': tx1.nonce})
在此之后,我立即收到 nonce_expired 错误。 我该如何进行?
可能,您的滑点太紧,尝试设置更高的 amountOutMin。 对于 nonce,您应该使用 web3.utils.toHex(txCount) 其中 txCount 是 web3.eth.getTransactionCount
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.