1.9 Ethereum State & Account Types
Ethereum state is a mapping from the address of the Ethereum accounts to the state contained within it as a data structure. It is implemented as a Modified Merkle-Patricia Tree: a combination of a Merkle tree and a Patricia tree with some changes that are specific to Ethereum.
Each of the Ethereum accounts has a unique 20 byte address associated with it, which is used by accounts to "talk to each other". Addresses are critical to how messaging works within the Ethereum protocol and how the accounts engage in transfer of value or information, since accounts need to be able to refer to each other using their addresses.
In addition, accounts have four fields:
nonce
: a counter that's used to make sure that each transaction can only be processed once used to prevent replay attacks.balance
: a number representing the amount of Ether that the account has at any point in time.code
: the smart contract code (absent in Externally Owned Accounts).storage
: the associated smart contract storage (absent in Externally Owned Accounts).
Account types
Ethereum has two account types:
Externally Owned Account (EOA): it is an account that is controlled by a private key.\
Anyone who has a private key can create a digital signature that can be used to control the Ether that is present in an EOA. These signatures can be used to sign transactions from the EOA, which in turn can trigger messages from the EOA to other accounts.\
These messages can result in a transfer of value or they can trigger smart contracts. An EOA does not have any associated code or storage.
Contract account: it is an account that is controlled by the code that is contained within that account.\
Unlike EOAs, contract accounts have an associated smart contract code and storage. Whenever the contract account receives a message, it triggers the code present and accesses any internal storage associated with it. When the code runs it can send messages to other accounts or even create new contracts.
In this sense, smart contracts can be thought of autonomous agents as they're always present in the execution environment of the Ethereum blockchain. They're always ready to be triggered by a transaction or a message that is sent to them.
Through their contract account they have access to the Ether balance and the contract storage. The execution of the code results in manipulation of this balance and the contract storage.
Last updated