get the last confirmed block in Tron network

204 views Asked by At

in the process of designing a cryptocurrency payment gateway, I faced this issue. in tronweb library there is a method called tronWeb.trx.getCurrentBlock() the problem is this method returns the latest block but this block in unconfirmed. so how can I get the latest confirmed block?

I tried this way: console.log("current block", await tronWeb.trx.getCurrentBlock()); and quickly checked the result in tronscan but the block was unconfirmed and became confirmed after 15 secconds.

1

There are 1 answers

0
Coinymous On

here is the solution:

    let confirmedCurrentBlock = (await tronWeb.trx.getConfirmedCurrentBlock()).block_header.raw_data.number

This method is not mentioned in the document. I found it in the core modules of tronweb.

Hope it will be useful.