[][src]Struct cosmwasm_std::BlockInfo

pub struct BlockInfo {
    pub height: u64,
    pub time: u64,
    pub time_nanos: u64,
    pub chain_id: String,
}

Fields

height: u64time: u64

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, converted from nanoseconds to second precision by truncating the fractioal part.

time_nanos: u64

The fractional part of the block time in nanoseconds since time (0 to 999999999). Add this to time if you need a high precision block time.

Examples

Using chrono:

use chrono::NaiveDateTime;
let dt = NaiveDateTime::from_timestamp(env.block.time as i64, env.block.time_nanos as u32);

Creating a simple millisecond-precision timestamp (as used in JavaScript):

let millis = (env.block.time * 1_000) + (env.block.time_nanos / 1_000_000);
chain_id: String

Trait Implementations

impl Clone for BlockInfo[src]

impl Debug for BlockInfo[src]

impl Default for BlockInfo[src]

impl<'de> Deserialize<'de> for BlockInfo[src]

impl JsonSchema for BlockInfo[src]

impl PartialEq<BlockInfo> for BlockInfo[src]

impl Serialize for BlockInfo[src]

impl StructuralPartialEq for BlockInfo[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.