Storage API

We've already encountered the decl_storage! macro in the appetizer on storage items. There is a rich storage API in Substrate which we will explore in this section.

For cryptocurrencies, storage might consist of a mapping between account keys and corresponding balances.

More generally, blockchains provide an interface to store and interact with data in a verifiable and globally irreversible way. In this context, data is stored in a series of snapshots, each of which may be accessed at a later point in time, but, once created, snapshots are considered irreversible.

Arbitrary data may be stored, as long as its data type is serializable in Substrate i.e. implements Encode and Decode traits.

The previous single-value storage recipe showed how a single value can be stored in runtime storage. In this section, we cover