Overview
Leo provides a rich set of built-in types designed for zero-knowledge circuit development. All types have explicit sizes and well-defined semantics.Integer Types
Leo supports both unsigned and signed integer types.Unsigned Integers
| Type | Size | Range |
|---|---|---|
u8 | 8 bits | 0 to 255 |
u16 | 16 bits | 0 to 65,535 |
u32 | 32 bits | 0 to 4,294,967,295 |
u64 | 64 bits | 0 to 18,446,744,073,709,551,615 |
u128 | 128 bits | 0 to 2^128 - 1 |
Signed Integers
| Type | Size | Range |
|---|---|---|
i8 | 8 bits | -128 to 127 |
i16 | 16 bits | -32,768 to 32,767 |
i32 | 32 bits | -2,147,483,648 to 2,147,483,647 |
i64 | 64 bits | -2^63 to 2^63 - 1 |
i128 | 128 bits | -2^127 to 2^127 - 1 |
Integer Literals
Integer literals must include a type suffix (e.g.,
42u8, 100i32). Leo does not perform implicit type coercion.Field Type
Thefield type represents a finite field element from the BLS12-377 scalar field.
- Size: ~253 bits
- Modulus: 8444461749428370424248824938781546531375899335154063827935233455917409239041
- Arithmetic is performed modulo the field prime
Group Type
Thegroup type represents a point on an elliptic curve.
- Represents points on the Edwards BLS12 curve
- Supports group operations (addition, scalar multiplication)
- Used in cryptographic operations
Scalar Type
Thescalar type represents a scalar value used for elliptic curve operations.
- Used with group operations
- Scalar multiplication:
scalar * group
Boolean Type
Thebool type represents truth values.
- Logical:
&&(and),||(or),!(not) - Comparison:
==,!= - Conditional:
if condition { ... } else { ... }
Address Type
Theaddress type represents an Aleo account address.
- 63-character string starting with
aleo1 - Represents a public key hash
- Used for ownership and authorization
String Type
Thestring type represents text data.
Strings in Leo are primarily used for debugging and are not stored on-chain.
Signature Type
Thesignature type represents a cryptographic signature.
Composite Types
Struct
User-defined composite type with named fields.Record
Private data structure that always includes anowner field.
- Records are private by default
- Always include an
owner: addressfield - Used for private state management
Tuple
Anonymous composite type with ordered elements.Array
Fixed-size collection of elements of the same type.- Fixed size known at compile time
- Zero-indexed access:
numbers[0] - All elements must be the same type
Vector
Dynamic-size collection (compile-time size determined).Mapping Type
On-chain key-value storage (only in program scope).- Declared at program level
- Publicly visible on-chain
- Accessed in finalizer functions
- Key and value types must be explicitly specified
Optional Type
Represents a value that may or may not be present.Future Type
Represents deferred computation in finalizers.- Used with the
Finaltype - Represents on-chain computation that executes during finalization
- Cannot be manipulated directly in Leo code
Unit Type
The unit type() represents the absence of a value.
Type Casting
Leo supports explicit type casting between compatible types.Type Inference
While Leo requires type annotations for function signatures, local variables can use type inference:Special Types
self.caller
Built-in value representing the caller’s address:block.height
Built-in value representing the current block height (in finalizers):Related Resources
Grammar Reference
Complete syntax specification
Examples
See types in action