Account Architecture

Published by Mario Oettler on

In this topic, we examine how accounts are constructed in Ethereum.

Ethereum stores the following information in an account:

nonce: The nonce is a counter that counts the number of transactions created by an externally owned account or the number of contracts created by a contract account. The nonce is important to avoid replay attacks where one transaction can be copied and submitted to the network a second time. If a transaction with this nonce exists already in a block. The new transaction with the same nonce is rejected.

balance: The balance shows how many ETH (in Wei) an account holds. This can be an externally owned account or a contract account.

codeHash: Contract accounts have code. The codHash is the hash of the code the EVM executes if a message call arrives. For EOAs, the hash is the hash of an empty string since EOAs don’t have code.

storageRoot: The storageRoot is the root hash of the Merkle-Patricia Trie that encodes the storage content. You can think of it as the fingerprint of the storage of this account. The storage contains all state variables of a contract account. If there is no variable, the storage root is the hash of an empty trie.

Categories: