Gnosis Chain API method that returns the latest block number of the blockchain. A block number is a hexadecimal number representing the block’s position in the blockchain. For example, the block number 0x69B5B
means that the block is the 432,987th block in the blockchain.
Get you own node endpoint today
Start for free and get your app to production levels immediately. No credit card required.
You can sign up with your GitHub, X, Google, or Microsoft account.
none
result
— the integer value of the node’s latest block number is synced to, encoded as hexadecimal. The block number is used to identify the block’s position in the blockchain and is updated every time a new block is added to the chain.eth_blockNumber
code examplesA possible use case for the eth_blockNumber
method in Gnosis Chain is for applications that need to be aware of the current block number—some applications may need to be mindful of the current block number to function correctly. For example, a DApp may use the current block number to determine the expiration date of a time-limited offer.
The following code uses the web3.js library and defines a function called getCurrentBlockNumber
. When called, this function returns the latest block number from the network, and you can use it in your DApp.
You can then use your application’s getCurrentBlockNumber
function to get the current block number whenever you need it. In this example, we use it to calculate on which block a special offer to a specific user will expire. We retrieve the block when we issue the offer to the user and add 121000
, which is approximately how many Gnosis Chain blocks are produced weekly. Now, in the offerExpires
constant, we have the last block when the user can exercise the special price.
Use the getCurrentBlockNumber
function to compare it to offerExpires
to know if the offer is still valid.
The latest block number.
The response is of type object
.
Gnosis Chain API method that returns the latest block number of the blockchain. A block number is a hexadecimal number representing the block’s position in the blockchain. For example, the block number 0x69B5B
means that the block is the 432,987th block in the blockchain.
Get you own node endpoint today
Start for free and get your app to production levels immediately. No credit card required.
You can sign up with your GitHub, X, Google, or Microsoft account.
none
result
— the integer value of the node’s latest block number is synced to, encoded as hexadecimal. The block number is used to identify the block’s position in the blockchain and is updated every time a new block is added to the chain.eth_blockNumber
code examplesA possible use case for the eth_blockNumber
method in Gnosis Chain is for applications that need to be aware of the current block number—some applications may need to be mindful of the current block number to function correctly. For example, a DApp may use the current block number to determine the expiration date of a time-limited offer.
The following code uses the web3.js library and defines a function called getCurrentBlockNumber
. When called, this function returns the latest block number from the network, and you can use it in your DApp.
You can then use your application’s getCurrentBlockNumber
function to get the current block number whenever you need it. In this example, we use it to calculate on which block a special offer to a specific user will expire. We retrieve the block when we issue the offer to the user and add 121000
, which is approximately how many Gnosis Chain blocks are produced weekly. Now, in the offerExpires
constant, we have the last block when the user can exercise the special price.
Use the getCurrentBlockNumber
function to compare it to offerExpires
to know if the offer is still valid.
The latest block number.
The response is of type object
.