Defining Variables

Leo supports let and const keywords for variable definition.

let defines an allocated program variable.

const defines a constant program variable.

allocated variables define private variables in the constraint system. Their value is constrained in the circuit on initialization.

constant variables do not define a variable in the constraint system. Their value is constrained in the circuit on computation with an allocated variable. constant variables cannot be mutable. They have the same functionality as const variables in other languages.

function add_one() → u8 {
let a = 0u8; // allocated, value enforced on this line
const b = 1u8; // constant, value not enforced yet
return a+b;
}