> For the complete documentation index, see [llms.txt](https://docs.kaio.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kaio.xyz/guide-to-using-kaio/smart-contracts/registries/eternal-registry-storage.md).

# Eternal Registry Storage

Eternal Storage for the KAIO Registries.

## Eternal Storage

Registries make use of the eternal storage pattern to store information. This pattern allows for storing data indexed by the hash of its identifier, instead of contiguously with other data. The data type used for identifiers is *bytes32,* this is preferred to something like *string* for efficiency. The convention chosen for these identifiers is applying the *keccak256* hash function to the string version of them. The majority of identifiers can be found in <mark style="color:red;">`Constants.sol`</mark>.

The Eternal Storage pattern has two main advantages:

* Upgrading contracts is much simpler, since all data stored in the Eternal Registry will not be affected or cause any issues.
* Variables can be added or deleted from the registry without having to change the contract. This is especially useful if old data becomes irrelevant, or if new data should be added to the registry. For example if one day a new data field needs to be filled out for all Dealers, this can be done without changing the Dealer Registry.

## Implementation & Data Types

The implementation of eternal storage in KAIO is done using the <mark style="color:red;">`EternalRegistryStorage.sol`</mark> contract. This contract supports the following data types with the following functions:

<table><thead><tr><th width="185">Data Type</th><th width="302">Set Function</th><th>Get Function</th></tr></thead><tbody><tr><td><code>Bool</code></td><td><em>_setBool()</em></td><td><em>getBool()</em></td></tr><tr><td><code>Uint256</code></td><td><em>_setUint()</em></td><td><em>getUint()</em></td></tr><tr><td><code>Address</code></td><td><em>_setAddress()</em></td><td><em>getAddress()</em></td></tr><tr><td><code>String</code></td><td><em>_setString()</em></td><td><em>getString()</em></td></tr><tr><td><code>Bytes32</code></td><td><em>_setBytes()</em></td><td><em>getBytes()</em></td></tr><tr><td><code>Batch</code> (<em>any combination of the above</em>)*</td><td><em>_setBatch()</em></td><td><em>getBatch()</em></td></tr><tr><td><code>Address[]</code></td><td><p><em>_setAddressArray()</em></p><p><em>_setAddressArrayIndexValue()</em></p><p><em>_pushAddressArray()</em></p><p><em>_deleteAddressArrayIndexValue()</em></p></td><td><em>getAddressArray(), getAddressArrayIndexValue()</em></td></tr></tbody></table>

*\*It is possible to get and set multiple values at once using batch functions, in order to save time and gas. This includes batch getting or setting values of different types.*
