estimate_block_number_for_timestamp_by_findblock
Documentation for eth_defi.timestamp.estimate_block_number_for_timestamp_by_findblock function.
- estimate_block_number_for_timestamp_by_findblock(chain_id, timestamp, attempts=5, sleep=60)
Estimate block number for a given timestamp.
To convert timestamps to block numbers
Uses FindBlock API, using
block/beforeAPIGets the block that was finaliesd at the timestamp or before it.
FindBlock API is free
Note
FindBlock API is too throttled to get the timestamp only but few blocks. I think we get 5 request per minute.
- Parameters
timestamp (datetime.datetime) – Timestamp to estimate the block number for
chain_id (int) –
- Returns
Estimated block number
- Return type