Nethereum – How to Get the Last Block Number in Ethereum

nethereum

I would like to get something similar to solidity

block.number - 1

using Nethereum

BlockParameter.CreateLatest()

Is latest here mean the Last BlockNumber been mined? Or do I need to minus 1?

Best Answer

var latestBlockNumber = await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync();

See the bottom example located here: https://nethereum.readthedocs.io/en/latest/Nethereum.Workbooks/docs/nethereum-gettingstarted-infura/

Which I posted above ^.

Related Topic