get_evm_block_time

Documentation for eth_defi.chain.get_evm_block_time function.

get_evm_block_time(chain_id, block_number=None)

Get block time for a chain at a given block, tolerating unknown chains.

Unlike get_block_time(), returns None for chains missing from EVM_BLOCK_TIMES instead of crashing, so callers can degrade gracefully (e.g. skip a time-based confirmation wait).

Parameters
  • chain_id (int) – Chain id to get the block time for.

  • block_number (Optional[int]) –

    Block at which the block time should be resolved.

    Currently unused. Reserved for resolving the block time dynamically in the future: block times change over chain upgrades (e.g. Polygon shortening blocks, Arbitrum Nitro) and some chains have variable block types (HyperEVM dual-block architecture), so a static per-chain value is only an approximation.

Returns

Block time in seconds, or None if the chain is not in the lookup table.

Return type

Optional[float]