{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Env",
"type": "object",
"required": [
"block",
"contract"
],
"properties": {
"block": {
"$ref": "#/definitions/BlockInfo"
},
"contract": {
"$ref": "#/definitions/ContractInfo"
}
},
"definitions": {
"BlockInfo": {
"type": "object",
"required": [
"chain_id",
"height",
"time",
"time_nanos"
],
"properties": {
"chain_id": {
"type": "string"
},
"height": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"time": {
"description": "Absolute time of the block creation in seconds since the UNIX epoch (00:00:00 on 1970-01-01 UTC).\n\nThe source of this is the [BFT Time in Tendermint](https://docs.tendermint.com/master/spec/consensus/bft-time.html), converted from nanoseconds to second precision by truncating the fractioal part.",
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"time_nanos": {
"description": "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.\n\n# Examples\n\nUsing chrono:\n\n``` # use cosmwasm_std::{BlockInfo, ContractInfo, Env, HumanAddr, MessageInfo}; # let env = Env { # block: BlockInfo { # height: 12_345, # time: 1_571_797_419, # time_nanos: 879305533, # chain_id: \"cosmos-testnet-14002\".to_string(), # }, # contract: ContractInfo { # address: HumanAddr::from(\"contract\"), # }, # }; # extern crate chrono; use chrono::NaiveDateTime; let dt = NaiveDateTime::from_timestamp(env.block.time as i64, env.block.time_nanos as u32); ```\n\nCreating a simple millisecond-precision timestamp (as used in JavaScript):\n\n``` # use cosmwasm_std::{BlockInfo, ContractInfo, Env, HumanAddr, MessageInfo}; # let env = Env { # block: BlockInfo { # height: 12_345, # time: 1_571_797_419, # time_nanos: 879305533, # chain_id: \"cosmos-testnet-14002\".to_string(), # }, # contract: ContractInfo { # address: HumanAddr::from(\"contract\"), # }, # }; let millis = (env.block.time * 1_000) + (env.block.time_nanos / 1_000_000); ```",
"type": "integer",
"format": "uint64",
"minimum": 0.0
}
}
},
"ContractInfo": {
"type": "object",
"required": [
"address"
],
"properties": {
"address": {
"$ref": "#/definitions/HumanAddr"
}
}
},
"HumanAddr": {
"type": "string"
}
}
}