glossary·2026-03-08·1 min read

Mapping

Mapping

A mapping is Aleo's public, on-chain state storage. It works like a key-value dictionary: each mapping has a name, a key type, and a value type, and anyone on the network can read its contents. Mappings are declared in Leo with the mapping keyword and can only be modified within final { } blocks that run on-chain after a transaction is confirmed.

Not all application state should be private. Token supply counters, public registries, governance vote tallies, and leaderboards need data that anyone can verify. Mappings handle public state while records handle private state, giving developers control over what is visible on-chain versus what stays encrypted.

Reads and writes happen during the on-chain finalize phase, not during off-chain private execution. Mapping operations are validated by validators through consensus, making the logic deterministic and publicly auditable. A single program can declare multiple mappings, and each can store an arbitrary number of entries limited only by on-chain storage fees.

Sources