How do I access chain state data from a contract?

291 Views Asked by At

Ho do I access storages or constants in a substrate chain from !ink smart contract? For example, in the chain, the timestamp(in Moment) is set as an extrinsic. How do I access the timestamp and put the variable in the smart contract?

let timestamp_now: u128: <access to chain when function is being called>

Image of the timestamp

1

There are 1 best solutions below

2
On

You can check https://paritytech.github.io/ink/ink_env/ Which provides functions as block_number and block_timestamp

ink! documentation in https://github.com/paritytech/ink#table-of-contents