Ethereum Series (11): Ethereum Account Management

Ethereum Series (11): Ethereum Account Management

Account

Accounts play a central role in Ethereum. There are two types of accounts: externally owned accounts (EOAs) and contract accounts. We will focus here on external accounts, which we will refer to as accounts. Contract accounts are referred to as contracts and are discussed in detail in the contracts section. It makes sense to group both external and contract accounts under the general concept of accounts, because these entities are so-called state objects. These entities have state: accounts have balances, and contracts have both balances and contract storage. The state of all accounts is the state of the Ethereum network, which is updated with every block and the network needs to reach consensus about Ethereum. Accounts are essential for users to interact with the Ethereum blockchain through transactions.

If we restrict Ethereum to only external accounts, and only allow transactions between external accounts, we will enter a "token" system that is less powerful than Bitcoin itself and can only be used to transfer Ether.

An account represents the identity of an external agent (such as a persona, mining node, or automated agent). An account uses a public key cryptographic image to sign transactions so that the Ethereum virtual machine can securely verify the identity of the transaction sender.

Key File

Each account is defined by a pair of keys, a private key and a public key. Accounts are indexed by addresses, which are derived from the public key by taking the last 20 bytes of the public key. Each private key/address pair is encoded in a keyfile. Keyfiles are JSON text files that can be opened and viewed with any text editor. The key part of the keyfile, the account's private key, is usually encrypted with the password you set when you created the account. Keyfiles can be found in the keystore subdirectory of your Ethereum node's data directory. Make sure to back up your keyfile regularly! See the Backing Up and Restoring Your Account section for more information. Creating keys is the same as creating an account.

  1. You don't have to tell anyone what you're doing.

  2. No need to sync with the blockchain.

  3. The client does not have to be running.

  4. You don't even have to be connected to the internet.

Of course the new account will not contain any Ether. But it will be yours and you can rest assured that no one can access it without your key and password.

It is safe to transfer entire directories or individual key files between any Ethereum nodes.

Warning: Please note that in case you add key files from a different node to another, the order of accounts may change. Make sure not to revert or change the indexes or code snippets in the manuscript.

Create Account

WARNING: Remember the password and "Backup the key file <backup-and-restore-accounts>". In order to send transactions from the account, including sending ether, you must have both the key file and the password. Make sure you have a backup of the key file and remember the password, and store them as securely as possible. There is no escape route here, if you lose the key file or forget the password, you will lose all your ether. It is impossible to enter the account without the password, and there is no forgotten password option. So make sure you don't forget your password.

Use geth account new

Once the geth client is installed, creating an account is just a matter of executing the geth account new command in the terminal.

Note that you do not need to be running the geth client or synced with the blockchain to use the geth account command.

 1
 $ geth account new
 1
2
3
4
 Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat Passphrase:
Address: {168bc315a2ee09042d83d7c5811b533620531f67}

For non-interactive use, you can provide a plain text password file as an argument to the --password flag. The data in the file contains the raw bytes of the password, optionally followed by a single newline.

 1
 $ geth --password /path/to/password account new

Warning: Use the --password flag only for testing or automating operations in a trusted environment. It is not recommended to store passwords in a file or expose them in any other way. If you use the --password flag with a password file, make sure the file is only readable and listable by you. You can do this on Mac/Linux with the following command:

 1
2
3
4
 touch /path/to/password
chmod 600 /path/to/password
cat > /path/to/password
>I type my pass

To list all accounts that currently have keyfiles in your keystore folder, use the list subcommand of the geth account command:

 1
 $ geth account list
 1
2
3
 account #0: {a94f5374fce5edbc8e2a8697c15331677e6ebf0b}
account #1: {c385233b188811c9f355d4caec14df86d6248235}
account #2: {7f444580bfef4b9bc7e14eb7fb2a029336b07c9d}

The file name format of the key file is UTC—<created_at UTC ISO8601>–

The accounts are listed in alphabetical order, but due to the timestamp format, they are actually listed in the order they were created.

Using geth console

In order to create a new account with geth, we must first start geth in console mode (or we can use geth attach to attach the console to an already running instance):

 1
2
3
4
5
 > geth console 2>> file_to_log_output
instance: Geth/v1.4.0-unstable/linux/go1.5.1
coinbase: coinbase: [object Object]
at block: 865174 (Mon, 18 Jan 2016 02:58:53 GMT)
datadir: /home/USERNAME/.ethereum

The console enables you to interact with the local node by issuing commands. For example, try this command to list the accounts:

 1
2
3
4
5
 > eth.accounts
{
code: -32000,
message: "no keys in store"
}

This means you don't have an account. You can also create an account from the console:

 1
2
3
4
 > personal.newAccount()
Passphrase:
Repeat passphrase:
"0xb2f69ddf70297958e582a0cc98bce43294f1007d"

Note: Remember to use a strong, randomly generated password.

We have just created our first account. If we try to list the accounts again, we will see our newly created account.

 1
2
 > eth.accounts
["0xb2f69ddf70297958e582a0cc98bce43294f1007d"]

Using Mist Ethereum Wallet

As opposed to the command line, there is now a GUI-based option for creating accounts: the "official" Mist Ethereum Wallet. The Mist Ethereum Wallet, along with its parent project Mist, is developed under the auspices of the Ethereum Foundation, hence the "official" status. The wallet application is available for Linux, Mac OS X, and Windows.

Warning: Mist Wallet is trial software, use at your own risk.

Creating an account with the GUI Mist Ethereum Wallet couldn’t be easier. In fact, your first account is created during the installation of the app.

  1. Download the latest version of the wallet app for your operating system. Since you will actually be running a full geth node, opening the wallet app will start syncing a copy of the entire Ethereum blockchain on your computer.

  2. Unlock the downloaded folder and run the Ethereum wallet executable file.

  3. Wait for the blockchain to be fully synchronized, follow the on-screen instructions, and your first account will be created.

  4. The first time you log in to the Mist Ethereum wallet, you will see the account you created during the installation process. It will be named the main account (Ethereum) by default.

  5. Creating additional accounts is easy; just click Add Account on the app's main screen and enter your desired password.

Note: Mist wallet is still under development, the specific steps listed above may change with updates. Original text: http://wangxiaoming.com/blog/2016/06/22/e11/

In the next article we will introduce "Ethereum Series (12): Creating a Secure Multi-Signature Wallet and Advanced Settings"

Thanks to Azure and Bob from the Chaoxi team for participating in the translation and proofreading of "Ethereum Homestead Documentation".


<<:  Coin Zone Trends: Bitcoin Price Trends Based on Big Data This Week (2016-08-30)

>>:  3 Key Advantages of Bitcoin over Traditional Investments

Recommend

The original value of Bitcoin

Bitcoin is a puzzle to be solved, not an excuse t...

London Law Firm Digitizes Contracts Using Bitcoin

A London law firm has announced plans to use bloc...

Face Reading - Beard

1. Hu Duo is rough People with long beards and th...

What is the difference between a man's nose and a woman's nose?

What is the difference between a man's nose a...

What does it mean to have a black mole in front of the ear?

What does it mean when a mole appears on the ear?...

Eating snacks all day during the Spring Festival

The Spring Festival is a time that everyone looks...

Face analysis: Are women with raised eyebrows good?

In physiognomy, is it good for a woman to have up...

The chin tells your fortune in old age

The current standard of beauty is a pointed chin,...

What are the specific features of a good person?

What are the specific features of a good person? ...

What kind of people are more afraid of suffering?

In this world, it is impossible to be completely ...

What kind of face indicates a short life span and early death

Qin Shi Huang spent his entire life researching t...