fetch_block_timestamp
Documentation for eth_defi.chain.fetch_block_timestamp function.
- fetch_block_timestamp(web3, block_number)[source]
Get the block mined at timestamp.
Warning
Uses eth_getBlock. Very slow for large number of blocks. Use alternative methods for managing timestamps for large block ranges.
Example:
# Get when the first block was mined timestamp = fetch_block_timestamp(web3, 1) print(timestamp)
- Parameters
web3 (web3.main.Web3) – Web3 connection
block_number (int) – Block number of which timestamp we are going to get
- Returns
UTC naive datetime of the block timestamp
- Return type