glossary·2026-03-08·1 min read

Finalize

Finalize

Finalize is the on-chain execution phase of an Aleo program function. The main function body runs off-chain with private inputs and produces a zero-knowledge proof. The finalize portion runs on-chain after validators verify that proof. It is the only way to read from and write to mappings, Aleo's public key-value storage. In current Leo syntax, this is a final { } block within a function.

Private computation (record manipulation, arithmetic on secret values) happens off-chain where only the user sees the data. Public state changes (incrementing a counter, updating a registry, recording a vote) happen on-chain in the finalize phase, where all validators execute the same deterministic logic.

Finalize blocks can only operate on public data and mapping state. They cannot access private inputs or outputs from the off-chain execution. If a finalize block fails (say, from an assertion or arithmetic overflow), the entire transaction is rejected even if the proof was valid. Values can be passed from the off-chain function body to the finalize block as public arguments.

Sources