From 3590a423cea26beec8c747980473266995b9053f Mon Sep 17 00:00:00 2001 From: Mohammed Alobaidi <37510951+moAlobaidi@users.noreply.github.com> Date: Mon, 26 Jun 2023 13:47:44 -0700 Subject: [PATCH] add block.height opcode to Leo docs --- documentation/leo/04_operators.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/documentation/leo/04_operators.md b/documentation/leo/04_operators.md index cde994b71e..807cc128f1 100644 --- a/documentation/leo/04_operators.md +++ b/documentation/leo/04_operators.md @@ -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