get_block_timestamp

Documentation for eth_defi.timestamp.get_block_timestamp function.

get_block_timestamp(web3, block_identifier, raw=False)

Get a block timestamp.

Slow method. Use only for individual queries.

By hand:

curl $JSON_RPC_MANTLE             -X POST             -H "Content-Type: application/json"             --data '{"method":"eth_getBlockByNumber","params":["0x1",false],"id":1,"jsonrpc":"2.0"}'
Parameters
  • raw – Don’t do slow Python datetime conversion, return raw integer timestamp

  • web3 (web3.main.Web3) –

  • block_identifier (Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, hexbytes.main.HexBytes, int]) –

Returns

Timezone naive UTC datetime

Return type

datetime.datetime | int