Building on Aptos: A Guide for Ethereum Developers
Ethereum to Aptos Cheat Sheet
Account Models
Data Storage Models
Contract-Level Storage and Account-Centric Storage
Solidity to Move
Typescript SDK
Aptos Developer Docs
Data Storage Models
Storage on Ethereum
Ethereum leverages Patricia Merkle Tree’s to store data. The storage system consists of 4 trees- World State tree (one and only, modified per block), Storage tree (per account, modified per block), Transaction tree (new per block) and Receipt tree (new per block). Here’s a diagram that will help visualize how Ethereum stores data:
![Example](/images/ethereum_data_storage.png)
Storage on Aptos
On Aptos, understanding how storage works is easier. Move programs read from and write to tree-shaped persistent global storage. In pseudocode, it looks something like this:
struct GlobalStorage { resources: Map<(address, ResourceType), ResourceValue> modules: Map<(address, ModuleName), ModuleBytecode>}
- Firstly, there is a storage location for resources—each entry in this map is identified by a combination of an account's address and the ResourceType. This combination serves as a unique label that leads to the value or details of that resource (ResourceValue).
- Secondly, there is a storage location for modules—this area is for storing smart contract (module) code. Here, each entry is identified by a combination of an account's address and the name of the module stored within that account. The value here is the bytecode of the module.
Structurally, global storage is a forest, where each tree represents an account’s data on the blockchain. Each tree has a unique starting point, similar to how every tree in a forest has its own place where it grows from. Each tree ‘branches’ out into the specific data related to that account, i.e. modules and resources.
![Example](/images/aptos_global_storage.png)
Leveraging the Move language, developers can write code that can create, delete and update resources in global storage using five instructions. These are known as Global Storage Operators and we will discuss this further in the next sections.