gpt4 book ai didi

node.js - 以太坊错误 : Transaction was not mined within 50 blocks

转载 作者:行者123 更新时间:2023-12-05 07:37:52 25 4
gpt4 key购买 nike

info:  Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!
at /opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-method/src/index.js:375:45
at tryCatcher (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:497:31)
at Promise._settlePromise (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:555:18)
at Promise._settlePromise0 (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:600:10)
at Promise._settlePromises (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:679:18)
at Async._drainQueue (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:125:16)
at Async._drainQueues (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:135:10)
at Immediate.Async.drainQueues (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:16:14)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)

这个错误在开发过程中不断重复,无论是在公共(public)测试网还是在有 1 个矿工的私有(private)网络中。这对前者来说是有道理的,因为存在竞争条件 b/w 矿工和 gas 价格上涨可能会有所帮助,但为什么它发生在我的私有(private)网络上,交易很少且采矿难度很低?

我使用 web3js send 方法发送两种类型的交易:

 /** executes contract method by creating transaction
* @param {string} from - payer address
* @param {string} to - payee address
* @param {int} amount - number of tokens
* @param {string} type - transaction type
*/
transferTokens(from, to, amount, type) {
if (type === 'transfer_to_admin' || type === 'transfer_from_user') {
return this.contract.methods.transferFrom(from, to, amount).send({ from })
.catch((err) => {
logger.info(err);
return Promise.reject(err);
});
}
if (type === 'transfer_from_admin') {
return this.contract.methods.transfer(to, amount).send({ 'from': this.coinbase })
.catch((error) => {
logger.info(error);
return Promise.reject(error);
});
}
}

其中transfertransferFrom是ERC20标准实现的Solidity函数。

有人知道如何避免/处理这个错误吗?

最佳答案

这是以太坊网络及其 fork 的老问题。增加 gas 无济于事,只是以太坊区 block 链的糟糕架构

这个错误不会被修复,如果交易没有被处理就等待一个小时,重复,否则你有在这个狗屎链中发送交易 2 次或更多次的风险

关于node.js - 以太坊错误 : Transaction was not mined within 50 blocks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48343868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com