在设计加密货币支付网关的过程中,我遇到了这个问题。 在 tronweb 库中有一个名为 tronWeb.trx.getCurrentBlock() 的方法 问题是这个方法返回最新的块,但是这个块未经确认。那么如何获取最新的确认区块呢?
我试过这样:
console.log("current block", await tronWeb.trx.getCurrentBlock());
并快速在 tronscan 中检查结果,但该区块未经确认,并在 15 秒后得到确认。
解决方案如下:
let confirmedCurrentBlock = (await tronWeb.trx.getConfirmedCurrentBlock()).block_header.raw_data.number
文档中没有提到这个方法。我在tronweb的核心模块中找到了它。
希望它会有用。