Search code examples
blockchainethereumweb3jscryptocurrency

What is the difference between the two parameters "latest" and "earliest" in web3.eth.getBlock()


I would like to know the difference between "latest" and "earliest" parameters in web3.eth.getBlock(), I couldn't find any explanation in the documentation.

My thoughts

Earliest Passing "earliest" gives you the last available block on or before the code is executed.

Latest Passing "lastest" only returns a new block after the code has been executed.

Please if anyone has information or documentation about this, kindly respond.


Solution

  • The getBlock() docs point to the defaultBlock for information about the values.

    "earliest" - String: The genesis block

    "latest" - String: The latest block (current head of the blockchain)

    "pending" - String: The currently mined block (including pending transactions)

    So "latest" is the newest block. "Earliest" on the other hand, is the oldest block.