Building a chain of etheric square blocks from scratch

Source: Internet
Author: User
Tags git clone

The recent block chain technology is very hot, Ethernet square is the block chain Technology 2.0 applications, with its intelligent contract function to the block chain increased infinite possibility, today, how to start from scratch to build the ether square.

(This article development environment is mac/linux, Ether Square client is go-ethereum, abbreviation Geth)

To install the GO environment before installing Geth, click to download


Install Geth with homebrew in Mac:

Brew tap Ethereum/ethereum
Brew Install Ethereum

Or clone under the GitHub source code, and then directly make

git clone https://github.com/ethereum/go-ethereum
CD Go-ethereum make
Geth

Add environment variables and check to see if the installation is successful

Geth version


environment installed, start building block chain

Create a new folder that stores your block-chain data. Inside the folder a new profile called Genesis.json is created to create your own Genesis block.

Contents of configuration file:

{"
  config": {"Chainid": "Homesteadblock":
        0,
        "Eip155block": 0,
        "Eip158block": 0
    }, "
  Coinbase"   : "0x0000000000000000000000000000000000000000", "
  difficulty": "0x020000",
  "Extradata "  :" ",
  " Gaslimit "   :" 0x2fefd8 ",
  " nonce "      :" 0x0000000000000042 ",
  " Mixhash "    :" 0x0000000000000000000000000000000000000000000000000000000000000000 ","
  Parenthash ":" 0x0000000000000000000000000000000000000000000000000000000000000000 ","
  timestamp "  :" 0x00 ",
  " Alloc "      : {}
}"

Initialize, create the Genesis block

CD your folder
Geth--datadir Data init Genesis.json

Here,--datadir is the directory where the data is saved, and we place it under the current folder under a directory called data;

Init is the initialized configuration.

Start Node

Geth--datadir Data--networkid 1108 Console

Here,--networkid means that the network ID of this chain is 1108, the public network ID of Ethernet square is 1;

Console represents the console that enters JS.

At this point, you should enter the console of JS.

Basic Commands

View Account
> eth.accounts
[]


Create an Account
> Personal.newaccount ()


View account Balances
> Eth.getbalance (eth.accounts[0])
0


Start mining
> Miner.start ()
Stop mining
> Miner.stop ()

The first time to dig a mine to wait for a period of time until the Dag file generation completed ...



Follow-up, the development of the etheric square wallet.


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.