Skip to main content

block_height

Function block_height 

Source
pub fn block_height() -> Result<u64>
Expand description

Returns the current block height.

Block height increments with each finalized batch (typically every 200ms). Useful for time-based logic, expiration checks, and replay protection.

§Returns

The current block height as a u64.

§Example

let current_height = context::block_height()?;
let expiration = storage.read_expiration()?;
 
if current_height > expiration {
    return Err(Error::new(ERR_EXPIRED));
}