0

I want to understand how the web3.js library works.

Could you please explain what happens "under the carpet" of the function

web3.eth.getBlock("latest")

Yes exactly the last block.

If you look in the ethereum specs, you can see that each block contains extra data. Which has a Parent hash, hence we can conclude that going down the blocks is pretty easy.

But I still do not understand how the library finds the last block (at low level)

1 Answer 1

0

When you initialize your web3 object, you pass it a RPC URL that is an URL pointing to a node which is synchronized to the blockchain, this is this node that will return the last block it know.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.