Blockchain development (i) An introduction to the private chain environment based on Ethereum __ Blockchain

Source: Internet
Author: User
Tags continue json
install Ubuntu System on window to build a private chain operation steps
The premise is that Geth has been installed, you can refer to the previous section to explain Step 1: Create a directory and Genesis.jsonCreate a directory in command-line mode, such as Geths, where the geths directory is named arbitrarily. Command: mkdir geths then a geths folder appears in the Ubuntu directory. Continue to enter the folder directory, create a file, Genesis.json, file name can also be arbitrary. Genesis.json File Contents: (Note that the version is too early to copy in, the operation will be error, you can change the content appropriately)
   {"
  config": {
        "Chainid": 666,
        "Homesteadblock": 0,
        "Eip155block": 0,
        "Eip158block": 0
    },
  "Alloc"      : {},
  "Coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty": " 0x20000 ",
  " Extradata "  :" ",
  " Gaslimit "   :" 0x2fefd8 ",
  " nonce "      :" 0x0000000000000042 " ,
  "Mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "Parenthash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}
Step 2: Execute commands to create a Genesis blockSwitch back to the command line, execute the command, create the creation block into the Geths directory, execute the command geth--datadir "./" Init Genesis.json the current geths directory will now add two folders Geth and KeyStore Geth the data stored in the blockchain is the keystore of the user information in the chain. Step 3: Create your own private chainGeth--datadir "./"--nodiscover console 2>>geth.log note Here output the print log to the log file Step 4: Create a user on your own private chainEnter the command eth.accounts, we will find the return value is [], because this time, although the ethereum private chain has been created, but there is no account. Enter the command personal.newaccount ("xxx"), the command will create a new user, the user's password is xxx. Of course the user can also change the XXX to 123, or 123456, or any password re-enter the command eth.accounts, we will find a new user was created, which means that we have created an account, Personal.newaccount () & Eth.accounts We can create a number of accounts. Step 5: The most important step is to start digging the mineExecute command Miner.start () on the command line and start digging on our blockchain until 100%. This ethereum private chain will be officially launched, and continue to generate the Ethereum. Note the point: 1. The ether coins dug into the mine will be covered by default in the first account, i.e. eth.acccounts[0]. 2. Mining is the basis for implementing smart contracts. If you stop digging, not only will the etheric currency stop generating, but the call of all smart contracts will not work. 3. If you really want to stop mining, you can execute command miner.stop () to stop digging 4. According to the above command, it should be possible to achieve the ethereum mining. If not, it could be a chain that existed before, and the previous data should be deleted. That is, delete the ~/.ethash folder and the files inside. 5. Usually someone appears miner.start () return null, and no information brush screen, stay in null, reason back to step 3 you print output to log, so unable to display, exit exit, rerun Geth--datadir "./"-- Nodiscover Console. STEP6: After mining starts, view the number of etheric coins in the master accountACC0 = Eth.accounts[0] Eth.getbalance (ACC0) as long as the result is not 0, that means mining success.
Exit Mining: Miner.stop () exit the current Geth, execute: Exit rerun Geth, go directly to step 3, do not need to perform the first two steps.

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.