Struct cosmwasm_std::BlockInfo
source · [−]Fields
height: u64
The height of a block is the number of blocks preceding it in the blockchain.
time: Timestamp
Absolute time of the block creation in seconds since the UNIX epoch (00:00:00 on 1970-01-01 UTC).
The source of this is the BFT Time in Tendermint,
which has the same nanosecond precision as the Timestamp
type.
Examples
Using chrono:
use chrono::NaiveDateTime;
let seconds = env.block.time.seconds();
let nsecs = env.block.time.subsec_nanos();
let dt = NaiveDateTime::from_timestamp(seconds as i64, nsecs as u32);
Creating a simple millisecond-precision timestamp (as used in JavaScript):
let millis = env.block.time.nanos() / 1_000_000;
chain_id: String
Trait Implementations
sourceimpl<'de> Deserialize<'de> for BlockInfo
impl<'de> Deserialize<'de> for BlockInfo
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for BlockInfo
Auto Trait Implementations
impl RefUnwindSafe for BlockInfo
impl Send for BlockInfo
impl Sync for BlockInfo
impl Unpin for BlockInfo
impl UnwindSafe for BlockInfo
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more