An Ethereum account is an entity with an ether (ETH) balance that can send transactions on Ethereum. Accounts can be user-controlled or deployed as smart contracts.
Accounts are a very beginner-friendly topic. But to help you better understand this page, we recommend you first read through our introduction to Ethereum.
Ethereum has two account types:
- Externally-owned – controlled by anyone with the private keys
- Contract – a smart contract deployed to the network, controlled by code. Learn about smart contracts
Both account types have the ability to:
- Receive, hold and send ETH and tokens
- Interact with deployed smart contracts
- Creating an account costs nothing
- Can initiate transactions
- Transactions between externally-owned accounts can only be ETH transfers
- Creating an account has a cost because you're using network storage
- Can only send transactions in response to receiving a transaction
- Transactions from an external account to a contract account can trigger code which can execute many different actions, such as transfering tokens or even creating a new contract
Ethereum accounts have four fields:
nonce– a counter that indicates the number of transactions sent from the account. This ensures transactions are only processed once. If a contract account, this number represents the number of contracts created by the account
balance– the number of Wei owned by this address. Wei is a denomination of ETH and there are 1e+18 Wei per ETH.
codeHash– All such code fragments are contained in the state database under their corresponding hashes for later retrieval. For contract accounts, this is the code that gets hashed and stored as the codeHash. For externally owned accounts, the codeHash field is the hash of the empty string.
storageRoot– Sometimes known as a storage hash. A 256-bit hash of the root node of a Merkle Patricia tree that encodes the storage contents of the account (a mapping between 256-bit integer values), encoded into the trie as a mapping from the Keccak 256-bit hash of the 256-bit integer keys to the RLP-encoded 256-bit integer values. This tree encodes the hash of the storage contents of this account, and is empty by default.
Diagram adapted from Ethereum EVM illustrated
An account is made up of a cryptographic pair of keys: public and private. They help prove that a transaction was actually signed by the sender and prevent forgeries. Your private key is what you use to sign transactions, so it grants you custody over the funds associated with your account. You never really hold cryptocurrency, you hold private keys – the funds are always on Ethereum's ledger.
This prevents malicious actors from broadcasting fake transactions because you can always verify the sender of a transaction.
If Alice wants to send ether from her own account to Bob’s account, Alice needs to create a transaction request and send it out to the network for verification. Ethereum’s usage of public-key cryptography ensures that Alice can prove that she originally initiated the transaction request. Without cryptographic mechanisms, a malicious adversary Eve could simply publicly broadcast a request that looks something like “send 5 ETH from Alice’s account to Eve’s account,” and no one would be able to verify that it didn’t come from Alice.
When you want to create an account most libraries will generate you a random private key.
A private key is made up of 64 hex characters and can be encrypted with a password.
The public key is generated from the private key using Elliptic Curve Digital Signature Algorithm. You get a public address for your account by taking the last 20 bytes of the public key and adding
0x to the beginning.
Here's an example of creating an account in the console using GETH's
1> personal.newAccount()2Passphrase:3Repeat passphrase:4"0x5e97870f263700f46aa00d967821199b9bc5a120"56> personal.newAccount("h4ck3r")7"0x3d80b31a78c30fc628f20b2c89d7ddbf6e53cedc"
It is possible to derive new public keys from your private key but you cannot derive a private key from public keys. This means it's vital to keep a private key safe and, as the name suggests, PRIVATE.
Contract accounts also have a 42 character hexadecimal address:
The contract address is usually given when a contract is deployed to the Ethereum Blockchain. The address comes from the creator's address and the number of transactions sent from that address (the “nonce”).
An account is not a wallet. A wallet is the keypair associated with a user-owned account, which allow a user to make transactions from or manage the account.
Know of a community resource that helped you? Edit this page and add it!