I have been trying to read up more on the block tags provided by the JSON-RPC API:

When requests are made that act on the state of Ethereum, the last default block parameter determines the height of the block.

The following options are possible for the defaultBlock parameter:

HEX String - an integer block number

String "earliest" for the earliest/genesis block

String "latest" - for the latest mined block

String "safe" - for the latest safe head block

String "finalized" - for the latest finalized block

String "pending" - for the pending state/transactions

I have also read through these posts, but was not satisfied with how much I understood it:

eth.pendingTransactions vs eth.getBlock('pending').transactions

What's the difference between "pending" block and txpool?

I am still a bit confused on how exactly the pending tag differs from the latest tag. From the above posts, I have noted that the pending tag constructs a "most-likely" block and then simulates against that as if it were mined. Is this always the case for all nodes?

Does this mean if I were to call eth_estimateGas using the pending tag, I would get a better estimate of what the final gas cost will be, rather than simulating against latest? If so, then surely it is better to always simulate against pending rather than latest.

Similarly, if I were to call eth_getLogs with the pending tag, would this pull logs from transactions that haven't been included yet?

I am open to more technical answers if possible, since I am not a beginner, just curious how exactly this works.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.