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
sourceimpl JsonSchema for BlockInfo
impl JsonSchema for BlockInfo
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moreimpl Eq for BlockInfo
impl StructuralEq for BlockInfo
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more