1

I am using subxt to get the block details, including the block number, hash, parent hash, timestamp, events and the extrinsics.

I am able to find most details, except the timestamp. Is there a way to get the block inclusion time?

Following is how I get the block details.

enter image description here

Is it possible to get the block timestamp using the subxt?

1 Answer 1

2

Timestamp is an item stored in storage.

https://github.com/paritytech/polkadot-sdk/blob/91deee7a1dba52e5e73d1a97d9fd5b8ad1e916a4/substrate/frame/timestamp/src/lib.rs#L156-L159C13

Simply retrieve it from storage.

Follow this example and replace system().account() with timestamp().now().

1
  • thank you, this solved my problem.
    – Yeou
    Commented Sep 7, 2023 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.