How to get the timestamp from the latest event on a contract using the etherscan.io api ?

I'm using the getLogs call this way: https://api.etherscan.io/api?module=logs&action=getLogs&fromBlock=6572886&toBlock=latest&address=xxx&apikey=xxx

Seems you need to use the fromBlock=xxx toBlock=xxx arguments but I can't figure out a convenient way to know if an event happened in the last day for example.

1 Answer 1


The blockchain doesn't have an understanding of "time", only "blocks"

In order to get close, your assumption is correct, you will need to estimate the average blocks per time period / hashrate, and query based on that

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.