Blockchain getting started tutorial ETH accounts and Basic Units

Source: Internet
Author: User
Enter eth. accounts on the command line to view the number of accounts in the blockchain and the Public Key address of each account. In the ETH system, a State is composed of an object called an "account" (each account consists of a 20-byte address) and a state transition between the two accounts that transfers value and information. The eth account contains four parts: a random number, which is used to determine the contract code of the current ethereum balance account of the counter account that can only be processed once for each transaction, if yes, the storage of the Account (empty by default). In short, each ETH account has a pair of public keys and private keys. The public key can be understood as the account address. Any other account can access this address. The private key can be understood as an encrypted password, this pair of public keys and private keys form a uniquely identified ETH account. For example, in the first ETH account eth. Accounts [0] created in the previous section, the address 0xbcf5b841303bc08026ce2d3b8f83498ffe42c12f is the public key, and the encrypted password is the private key. To add an account, run the "personal" command. newaccount ("123") to create a new account (note that 123 can be changed to any other password) when the ETH private chain is mining, the coins dug will be stored in the first ETH account, that is, Eth. in accounts [0], and eth. accounts [1] does not have any ether coins by default. In this case, we can use the following command to view the ether balance in eth. Accounts [0. Eth. getbalance ("0xbcf5b841303bc08026ce2d3b8f83498ffe42c12f") how to convert the etherecoin between two accounts. Previously, the Public Key (address) of each account is the core of all ETH account operations, but the address string is too, we use acc0/acc1 to represent accounts [0] and [1] respectively, and set to transfer 0.01 ether coins 1.> acc0 = eth. accounts [0] 2. "0xbcf5b841303bc08026ce2d3b8f83498ffe42c12f" 3.> acc1 = eth. accounts [1] 4. "0xb8b12a801b610176935a15321f77b48dd5c0c448" 5.> amount = WebSphere 3.towei (0.01) 6. "10000000000000000" in this case, we can use eth. sendtransaction to switch 0.01 ether coins from acc0 Move to acc1. 1.> eth. sendtransaction ({from: acc0, to: acc1, value: Amount}) is a protection mechanism of Eth. The account is automatically locked at intervals, at this time, any conversion of ethereum between accounts will be rejected unless the account is unlocked. in this case, we need to execute personal. unlockaccount (acc0) and enter the password to unlock acc0. 1.> personal. unlockaccount (acc0) 2. unlock account 0xbcf5b841303bc08026ce2d3b8f83498ffe42c12f3. passphrase: 4. true5.> at this time, we re-execute the command eth. sendtransaction ({from: acc0, to: acc1, value: Amount}), the result is as follows: 1.> eth. sendtransaction ({from: acc0, to: acc1, value: Amount}) 2. "0xeea74dd5ff3f1287614d52ebb674edb93e8c5e51e4296835044d3d858d3d9f10" 3.> eth. getbalance (acc1) 4.100000000000000005.> we can see that acc1 has a value of 10000000000000 at this time. 000, instead of the previous 0. But why is the value 0.01ether so big? In fact, this is correct. You only need to enter the web3.fromwei (10000000000000000, "Ether") command. 1.> web3.fromwei (10000000000000000, "Ether") 2. "0.01" The basic unit of ether coins the smallest unit of ether coins is Wei, which is also the default unit of the command line. Then, every 1000 coins are entered into one unit, which is 1 in sequence. kwei (1000 Wei) 2. mwei (1000 Kwei) 3. gwei (1000 mwei) 4. szabo (1000 GWEI) 5. finney (1000 Szabo) 6. ether (1000 Finney) is simply 1 ether = 1000000000000000000 Wei (that is why we transferred 0.01 etherecoins in the previous chapter, but the results show a long time) how to convert ether and Wei 1. ether-> Wei: web3.towei2.> web3.towei (1) 3. "1000000000000000000" 4.> web3.towei (1.3423423) 5. "1342342300000000000" 6.> webSphere 3.towei (0.00034) 7. "340000000000000" 1.> 2.wei-> ether: web3.fromwei3.> webSphere 3.fromwei (10000000000000000) 4. "0.01" 5.> webSphere 3.fromwei (1000000000000000000) 6. "1" 7.>

Blockchain getting started tutorial ETH accounts and Basic Units

Related Article

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.