Ethereum is a decentralized blockchain with smart contracts functionality. It has the largest market capitalization after Bitcoin and the most active blockchain with a very good and active developer community. Ether(ETH) is the native currency in Ethereum Blockchain.
In this blog, I am going to explain the two types of accounts on the Ethereum blockchain.
In Ethereum, the state is made up of objects called accounts. An account is identified by a 20-byte address. There will be state transitions happening through accounts which is nothing but the direct transfer of information and value between accounts.
Ethereum has 2 types of accounts
- Externally Owned Account
- Contract Accounts
Externally Owned Accounts
These types of accounts are controlled by private keys. These are user accounts.
For example, the account we create with Metamask.
Metamask calls eth_requestAccounts api on ethereum blockchain which returns a hexadecimal address. You get a public address(your wallet address) by taking the last 20 bytes of the hash of the hexadecimal address returned and adding 0x to the beginning.
You can read more about metamask on metamask docs.
Contract Accounts
The contract accounts are created when the contract is deployed on the blockchain and unlike externally owned accounts, these accounts are controlled by code.
Differences
- Both types of accounts can receive, send, hold ETH and ERC-20 Tokens(Token standard on Ethereum blockchain) and interact with other smart contracts deployed on the blockchain
- The creation of externally owned accounts does not cost anything whereas contract accounts cost ETH, as they require storage on the blockchain.
- External accounts can initiate transactions whereas the contract accounts can only send the transaction when it receives a transaction. When a contract account receives a transaction, the code triggers and can do different types of actions such as transfer ERC-20 token or ETH, create new smart contracts, or call other smart contracts.
- Transfers between two Externally owned accounts are limited to ETH transfers or ERC-20 Tokens.
An Ethereum Account
An Ethereum account consists of four fields
- nonce - This field is a counter to make sure transactions are processed only once on the blockchain. This indicates the number of transactions sent from an account. In contract accounts, this field represents the number of contracts created by the account
- balance - this field indicates accounts ether balance in wei. ( 1 ETH = 1,000,000,000,000,000,000 wei (1018) )
- codeHash - For external accounts, this field is an empty string. For smart contacts, it is the account's contract code.
- storageRoot - Also known as storage hash, it represents an account's storage and it is empty by default.
Post a Comment