Function gcore::exec::block_height
source · pub fn block_height() -> u32
Expand description
Get the current block height.
The block height serves to identify a particular block. This information can be used to enable many scenarios, like restricting or allowing some functions until a particular block height is reached.
§Examples
Send a reply after the block height reaches the number 1000:
use gcore::{exec, msg};
#[no_mangle]
extern "C" fn handle() {
if exec::block_height() >= 1000 {
msg::reply(b"Block #1000 reached", 0).unwrap();
}
}