Skip to main content


It is possible to declare a constant in an expression with the let c = v in e declaration expression: constant c is replaced by the evaluation of expression v in expression e.

For example,

const reward =
let is_owner = (caller = owner) in
if not is_owner then
5% * balance
/* is_owner is not defined beyond expression scope */

The expression above also uses the conditional expression if then else.

Constant declaration may be useful to factorise computation in more complex expressions.

Note that the scope of the declared constant is limited to the expression.