Skip to content

EternalStorage

Description

This is an implementation of the well-known eternal storage smart contract pattern, described in more detail here and here.

In short, it is a key-value store for variables which are retrieved by a byte string, typically a hash of their name and an index.

The contract is architected this way so that the access pattern is uniform and the memory layout is not dependent on implementation or compilation details. In this way, smart contracts can retain state between updates while minimising the difficulty and expense of migrating this information.

Each type of variable has its own mapping, along with getters and setters. As this entails some replication, this document will express functions and variables generically with the type variable š¯•‹, where š¯•‹ \in {uint, string, address, bytes, bytes32, bool, int}. This notation is used slightly abusively, standing in for both names and types; in the former case, substitution is in camelCase. More complex types, such as structs and nested mappings, are not supported.

Source: EternalStorage.sol

Architecture


Inheritance Graph

EternalStorage inheritance graph


Variables


š¯•‹Storage

A mapping from keys to values of type š¯•‹.

Type: mapping(bytes32 => š¯•‹)


Functions


constructor

Initialises the inherited State instance.

Details

Signature

constructor(address _owner, address _associatedContract) public

Superconstructors


getš¯•‹Value

Return the value associated with a particular key in the š¯•‹Storage mapping.

In theory this function could be eliminated by making the storage mapping public, but providing it makes accessor naming more consistent.

Details

Signature

getš¯•‹Value(bytes32 record) external view returns (š¯•‹)

Note

If š¯•‹ is string or bytes, the result is returned in memory rather than storage.


setš¯•‹Value

Sets the value associated with a particular key in the š¯•‹Storage mapping.

Details

Signature

setš¯•‹Value(bytes32 record, š¯•‹ value) external

Modifiers


deleteš¯•‹Value

Deletes the value associated with a particular key in the š¯•‹Storage mapping.

Details

Signature

deleteš¯•‹Value(bytes32 record) external

Modifiers