Ethereum/ethereum to build a single-node private chain to carry out mining

Source: Internet
Author: User
Tags json
Create a private chain node directory
cd/opt
sudo mkdir privatechain
cd privatechain
vim Genesis.json #创世块
{"
  config": {
        "Chainid": Ten,
        "Homesteadblock": 0,
        "Eip155block": 0,
        "Eip158block": 0
    },
  "Alloc"      : {},
  "Coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty": " 0x02000000 ",
  " Extradata "  :" ",
  " Gaslimit "   :" 0x2fefd8 ",
  " nonce "      :" 0x0000000000000042 ",
  " Mixhash "    :" 0x0000000000000000000000000000000000000000000000000000000000000000 " ,
  "Parenthash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
Save exit.
#初始化创始块节点, and set the data directory
geth--datadir "./data/00" Init Genesis.json
Output similar to this will appear

#启动节点, plus console, indicates that the command line is enabled after startup

Similar output:

Now that the blockchain private network has been built successfully, the following can be done digging in this newly built environment.

The following are common commands:

#查看账户
eth.accounts 
#新建账户
personal.newaccount ("xxxxx")
Personal.newaccount ()
#获取账户信息
Eth.getbalance ("Account ID")
#给账户设置变量名
user1 = eth.accounts[0]  #将第一个账户设置为user1
#解锁账户 (default all accounts are locking status, To unlock when executing the trade)
Personal.unlockaccount (user1)
#交易 (User1 sends a few dollars to User2)
eth.sendtransaction ({from:user1 , to:user2,value:8})

Mining Operation Miner.start ()


# Unlock account
Personal.unlockaccount (user1)
Personal.unlockaccount (user2)
# Execute Trades
Eth.sendtransaction ({from:user1,to:user2,value:8})

# view User2 account
eth.getbalance (user2)
You'll find your account balance is  0   
. If you want to complete the transaction, you will have to carry out the mining
Miner.start () # Many of the documents say that doing this will return true, but will actually return null for reasons unknown, not carefully studied

Like address 0x0b52 ... Write the transaction 0xab24:, written in Block 8, we can view block 8 for verification
# view User2 account
eth.getbalance (user2)
This will return 8.

Here to build the Ethereum blockchain private node, the execution of mining, the transaction has been completed.


There are a lot of pictures in other materials are intercepted images, is in Babbitt data, just for reference, follow the text to execute the process, can also complete the operation.

No development zone block chain, so ... Superficial understanding

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.