agent0.utils.block_number_before_timestamp

Get the number of the block that is at or immediately before the given timestamp.

Functions

block_number_before_timestamp(→ eth_typing.BlockNumber)

Finds the closest block number that is before or at the given block time.

Module Contents

agent0.utils.block_number_before_timestamp.block_number_before_timestamp(web3: web3.Web3, block_timestamp: web3.types.Timestamp | int) eth_typing.BlockNumber

Finds the closest block number that is before or at the given block time.

Parameters:
  • web3 (Web3) – The web3 instance.

  • block_timestamp (BlockTime | int) – The block time to find the closest block to.

Returns:

The closest block number to the given block time.

Return type:

BlockNumber