The account model is the main accounting model of the shared ledger (blockchain). Like the UTXO model, it is used to record, store, and execute on-chain transactions. The account model is used by Ethereum.
What is the UTXO model? What are the characteristics of the UTXO model? Please refer to the "What is the UTXO model" chapter.
The account model uses the balance in the account As the accounting unit of measurement for transactions. This is its main difference from the UTXO model. The UTXO model uses the unspent cryptocurrency portion of a transaction as an accounting measure. The account model can be thought of as a digital version of a traditional bank. In this model, digital assets are recorded as balances within accounts, just like traditional bank accounts.
The account model is a calculation model. When a transaction occurs, the system will trigger the node to change the account balance according to the user's transaction instructions. The system then calculates the change in the balance in each account and records the latest status of the balance.
In Ethereum, the status of an account is not stored on the blockchain, but is calculated and stored locally by the node. Only transaction instructions are stored on the blockchain.
In Ethereum, there are two types of accounts: external owned accounts (EOA) and contract accounts.
Refers to a user account controlled by a private key.
Users can create such accounts in the MetaMask wallet. Each EOA has a private key and an address, and it can directly initiate transactions.
Refers to the account controlled by the smart contract code.
Unlike EOA, the contract account does not have a private key, it has a smart contract code. The account is run by its smart contract code. The code is recorded on the chain when the contract account is created and executed by the EVM.
A contract account cannot initiate transactions like EOA. It can only call functions within other contracts to respond to transaction instructions. Simply put, the trading instruction will call the function in the contract, extract parameters (such as the amount of $ETH) to change the account balance, and complete the transaction.
Whenever someone sends a transaction to the contract address, it causes the contract to run in the EVM with the transaction as its input. Transactions sent to a contract address may have $ETH or data, or both. If they contain $ETH, it will be "deposited" into the contract balance. If they contain data, the data can specify a named function in the contract and call it, passing arguments to the function.
In the account model, the outcome of the transaction depends on the balance status. The account balance must be greater than the transaction output. Therefore, transaction sequence verification and balance verification are very important for networks using the account model. Nodes in the account model check the sender's balance status when receiving a transaction instruction (to see if it is greater than or equal to the transferred output amount).