简体   繁体   English

将以太坊交易发送到Rinkeby网络时遇到“置换交易价格低估”错误?

[英]Getting “replacement transaction underpriced” errors when sending Ethereum transactions to the Rinkeby network?

I'm getting intermittent "replacement transaction underpriced" errors on the Rinkeby network on the server side of my Node.JS dApp. 我在Node.JS dApp的服务器端的Rinkeby网络上遇到间歇性的“置换交易价格低估”错误。 I am using the exact amount for estimated gas in my transaction send() call returned to me by the estimateGas() call. 我用我的交易发送用于估计气体的确切数额()调用由还给我estimateGas()调用。 In my call options, I am adding both a gas and gasLimit field just to be safe with the estimated gas value returned by estimateGas() in the options object. 在我的看涨期权中,为了安全起见,我同时添加了一个gasgasLimit字段,并在options对象中由gasLimit estimateGas()返回的估计气体值。 Does anyone know how to fix this? 有谁知道如何解决这一问题?

On an unrelated issue. 在一个无关的问题上。 Much to my dismay, just submitting a transaction through Metamask to the Rinkeby network takes about 16 to 30 seconds. 令我非常沮丧的是,仅通过Metamask向Rinkeby网络提交事务大约需要16到30秒。 Note, I mean from the time the Metamask extension pops up to the time my client side code regains control. 请注意,我的意思是从Metamask扩展弹出到我的客户端代码重新获得控制的时间。 I am not talking about the time it takes to get a transaction confirmed/mined by the network. 不是在说网络确认/挖掘交易所需的时间。 Having said that, I am beginning to wonder if Metamask does not return control to you until the transaction has been mined. 话虽如此,我开始怀疑在挖掘交易之前Metamask是否不会将控制权还给您。 Is that the case? 是这样吗

Here is a code fragment of the code I use to send the transaction to Rinkeby (or whatever network I'm testing on): 这是我用来将交易发送到Rinkeby(或我正在测试的任何网络)的代码的代码片段:

contractMethodToCall.estimateGas(
    { from: publicAddr, gasPrice: 20000000000, gas: 1500000})
.then(function(estimatedGas) {
    if (estimatedGas <= 0)
        throw new Error("The estimated gas for the transaction is zero.");

    const rawTx = {
        nonce: fromNonce,
        gasPrice: gasPriceGwei,
        // Use the estimated gas.
        gasLimit: estimatedGas,
        // Adding both gas and gasLimit just in case.
        gas: estimatedGas,
        to: contractAddr,
        value: '0x00',
        data: encodedAbiForCall
    }

    let tx = new Tx(rawTx);

    // Sign the transaction using our server private key in Buffer format.
    tx.sign(privateKeyBuffer);

    let serializedTx = '0x' + tx.serialize().toString('hex');

    return web3.eth.sendSignedTransaction(serializedTx);
});

It sounds like you found the cause of your issue from your comment. 听起来您是从评论中找到问题的原因。 But, to add clarity for others who see the same issue, the error is not solely because of a duplicate nonce. 但是,为使看到相同问题的其他人更清楚,该错误不仅是由于重复的随机数。 This error will occur when a transaction is submitted with a nonce that is already used in another pending transaction AND the gas price is the same (or less than) the pending transaction. 当提交的随机数已用于另一项挂起的事务中且天然气价格与挂起的事务相同(或小于)时,将发生此错误。

You can submit a transaction using the same nonce if you use a higher gas price. 如果您使用更高的汽油价格,则可以使用同一随机数提交交易。 Miners will always pick the higher priced transaction for pending work, so this is a way to cancel a pending transaction or resubmit a transaction that is being ignored due to low gas prices. 矿工将始终选择价格较高的交易来处理待处理的工作,因此这是取消待处理的交易或重新提交因汽油价格低而被忽略的交易的一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用单个交易处理 2 个以太坊交易 - Process 2 Ethereum Transactions with single Transaction 即使gas价格非常高,也没有在rinkeby网络上开采交易 - transaction not mined on rinkeby network even with a very high gas price 以太坊智能合约自动交易-有可能吗? - Ethereum smartcontract automatical transactions - is it possible? 错误:在调用 Multicall Contract ethereum 的聚合 function 时发送交易需要签名者 - Error: sending a transaction requires a signer while ccalling aggregate function of Multicall Contract ethereum hardhat:将 NFT 部署到 rinkeby 网络时的问题 - hardhat : Issues while deploying a NFT to rinkeby network 发送交易时未找到 Blockhash - Blockhash not found when sending transaction Metamask (web3) 连接钱包并发送交易 - 如何将区块链更改为 Bianance 智能链 (BEP-20) 网络而不是以太坊? - Metamask (web3) connect wallet and send transaction - how to change blockchain to Bianance smart chain (BEP-20) network instead of Ethereum? 发送 API 请求时出现 Getting.network 错误 - Getting network error while sending an API request 替代.get(“ transaction”)。commit() - replacement for .get(“transaction”).commit() Solidity 与 Rinkeby 测试网络 | 未捕获的错误:无效地址 - Solidity w/ Rinkeby Test Network | Uncaught Error: invalid address
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM