Skip to content

Commit

Permalink
add block.height opcode to Leo docs
Browse files Browse the repository at this point in the history
  • Loading branch information
moAlobaidi committed Jun 26, 2023
1 parent 685466b commit 3590a42
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions documentation/leo/04_operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,30 @@ Checks whether `first` and `second` are not equal, halting if they are equal.
[Back to Top](#table-of-standard-operators)
***

### `block.height`

```leo
transition matches(height: u32) {
return then finalize(height);
}
finalize matches(height: u32) {
assert_eq(height, block.height);
}
```

#### Description

The `block.height` operator is used to fetch the latest block height in a Leo program. It represents the number of
blocks in the chain. In the above example, `block.height` is used in a `finalize` context to fetch the latest block
height in a program.

#### Note:
* The `block.height` operator can only be used in a `finalize` context. Using it outside a `finalize` context will result in a compilation error.
* The `block.height` operator doesn't take any parameters.

[Back to Top](#table-of-standard-operators)
***

### `BHP256::commit`

```leo
Expand Down

0 comments on commit 3590a42

Please sign in to comment.