Ethereum Serial (11): Ethereum Account Management

Source: Internet
Author: User
Tags object object
Account

The account plays a central role in Ethereum. There are two types of accounts: external accounts (EOAS) and contract accounts. We'll focus on the external account here, which will be referred to as the account. Contract accounts are referred to as contracts and are discussed specifically in the contract chapters. The general concept of putting both external and contractual accounts into accounts is justified, since these entities are so-called state objects. These entities have a status: The account has a balance, the contract has both the balance and the contract is stored. The status of all accounts is the state of the Ethereum network, the Ethereum network is updated with each chunk, and the network needs to reach a consensus on ethereum. Accounts are essential for users to interact through trading and ethereum blockchain.

If we restrict ethereum to an external account and only allow transactions between external accounts, we will enter the "token" system, which is not as powerful as the bitcoin itself and can only be used to transfer the etheric currency.

The account represents the identity of an external agent (such as a persona, mining node, or automatic agent). The account uses public key cryptography images to sign transactions so that the ethereum virtual machine can securely verify the identity of the sender of the transaction.

key File

Each account is defined by a pair of keys, a private key, and a public key. The account is indexed by address and the address is derived from the public key, taking the last 20 bytes of the public key. Each pair of private keys/addresses are encoded in a key file. The key file is a JSON text file that can be opened and browsed with any text editor. The key part of the key file, the account private key, is usually encrypted with the password you set when you created the account. The key file can be found under the KeyStore subdirectory of the Ethereum node data directory. Make sure to back up your key files frequently. See the Backup and Recovery Accounts section for more information. Creating a key is the same as creating an account. You don't have to tell anyone what you're doing. No need to synchronize with blockchain. You do not have to run the client. You don't even have to connect to the network.

Of course the new account does not contain any etheric currency. But it will be yours, you can rest assured that without your keys and passwords, no one can enter.

It is safe to convert the personal key file between the entire directory or any Ethereum node.

Warning: Please note that in case you add a key file to another node from a different node, the order of the account may change. Make sure that you do not reply to or alter the index or code snippet in the manuscript. Create an account

Warning: Remember the password and "Back up the key file <backup-and-restore-accounts>". In order to send a transaction from an account, including sending an Ethernet token, you must have both a key file and a password. Make sure that your key files have a backup and remember the passwords to store them as securely as possible. There is no escape path, and if the key file is lost or forgotten, all the etheric coins will be lost. No password is not possible to enter the account, nor forget the password option. So be sure not to forget the password. using Geth account new

Once the Geth client is installed, creating an account is only a matter of executing the Geth accounts new command at the terminal.

Note You do not have to run the Geth client or synchronize with the blockchain to use the Geth account directive.

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

For non-interactive use, you can provide a plain text password file as the-password symbol for the variable. The data in the file contains the original bytes of the password, and you can choose to follow the new line separately.

1
$ geth--password/path/to/password Account New

Warning: Use the-PASSWORD flag only for testing or automatic operation in a trusted environment. It is not recommended to save the password in a file or expose it in any other way. If you use the-PASSWORD flag with a password file, make sure that the file is readable and list only to you. You can do this in the Mac/linux system with the following directives:

1
2
3
4
Touch/path/to/password
chmod 600/path/to/password
cat >/path/to/password
>i type My pass

To list all the accounts of the key files currently in your KeyStore folder, use the LIST subcommand of the Geth account directive:

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

The key file has a filename format of utc-<created_at UTC iso8601>–

。账号列出时是按字母顺序排列,但是由于时间戳格式,实际上它是按创建顺序排列。

using the Geth console

In order to create a new account with Geth, we must first turn on Geth in console mode (or you can use Geth attach to attach the console to an already running case):

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, Jan 02:58:53 GMT)
DataDir:/home/username/.ethereum

The console enables you to interact with local nodes by issuing instructions. For example, try this command that lists the accounts:

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

This means that you do not 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 security-strong, randomly generated password.

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

1
2
> eth.accounts
["0xb2f69ddf70297958e582a0cc98bce43294f1007d"]
using the Mist ethereum wallet

For the opposite command line, there is now a GUI-based option that can be used to create an account: "Official" mist ethereum wallet. Mist Ethereum Wallet, and its parent project Mist, was developed under the auspices of the Ethereum Foundation and is therefore an "official" status. The Wallet app has Linux, Mac OS x and Windows available versions.

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

It's easy to create an account with the GUI Mist ethereum wallet. In fact, the first account was created during application installation. Download the latest version of the Wallet app according to your operating procedures. Since you will actually run a full geth node, opening the Wallet app will start synchronizing the entire Ethereum blockchain on your computer. Unlock the downloaded folder and run the Ethereum wallet executable file. Wait for the blockchain to be fully synchronized, follow the onscreen instructions, and the first account is created. 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 the default name of the main account (in Techcode) to create another account easily, just click on the app's main interface to add an account, enter the required password.

注意: Mist钱包仍在开发中,以上列出的具体步骤可能会随着更新有所变更。原文:http://wangxiaoming.com/blog/2016/06/22/e11/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.