How To Create Your Own Ethereum Network

in #utopian-io7 years ago (edited)

Repository

https://github.com/ethereum/go-ethereum

6.png

What Will I Learn?

  • During this project, we'll have a look at the mechanics of creating your own Ethereum blockchain.

  • First, an Ether local testnet.

  • Next, a clone of the Ether blockchain.

  • Last, how to mine your new super-low-difficulty (in our case) blockchain.

What problems does this guide solve?

  • Finding documentation on how to do this leads to conflicting opinions, broken python scripts, and loads of worry

  • We use a pre-generated genesis.json file which saves a lot of hassle

  • Learn with me as I figure out how to do stuff, find some stuff impossible on my machine, and CPU mine about 50+ 'Ether' on Epoch 0 with a network difficulty of... 0x1 (just 1!)!

Requirements

System Requirements
  • We run the code to acquire the dependencies to build and run geth on Windows 10.

  • For the testnet section: node, npm, git on Windows, MetaMask or some other wallet

Personal Requirements
  • Familiarity with Blockchain

  • Familiarity with Ether, Eth tokens and Ethereum, specifically

  • And the most important is: don’t panic!

Difficulty

  • Intermediate

Description

  • Session 1: In case you were after a local Ethereum testnet...

  • Creating your own Ether local testnet for testing apps, etc with test Ether

We'll install and run ganache GUI and CLI on our local VM, then manipulate Ether and create a set of contracts and find some tokens!

  • Session 2: Defining scope of project and looking at the steps involved and start!

  • Source tutorial and build project plan, start by downloading Ethereum git repo and making where we'll eventually be able to mine (not a VM)

From: https://github.com/ethereum/go-ethereum/wiki/Installation-instructions-for-Windows

Compiling geth with tools from chocolatey

The Chocolatey package manager provides an easy way to get the required build tools installed. If you don't have chocolatey yet, follow the instructions on https://chocolatey.org to install it first.

Then open an Administrator command prompt and install the build tools we need:

C:\Windows\system32> choco install git
C:\Windows\system32> choco install golang
C:\Windows\system32> choco install mingw

Installing these packages will set up the Path environment variable. Open a new command prompt to get the new Path. The following steps don't need Administrator privileges.

Please ensure that the installed Go version is 1.7 (or any later version).

First we'll create and set up a Go workspace directory layout, then clone the source.

OBS If, during the commands below, you get the following message:

WARNING: The data being saved is truncated to 1024 characters. Then that means that the setx command will fail, and proceeding will truncate the Path/GOPATH. If this happens, it's better to abort, and try to make some more room in Path before trying again.

C:\Users\xxx> set "GOPATH=%USERPROFILE%"
C:\Users\xxx> set "Path=%USERPROFILE%\bin;%Path%"
C:\Users\xxx> setx GOPATH "%GOPATH%"
C:\Users\xxx> setx Path "%Path%"
C:\Users\xxx> mkdir src\github.com\ethereum
C:\Users\xxx> git clone https://github.com/ethereum/go-ethereum src\github.com\ethereum\go-ethereum
C:\Users\xxx> cd src\github.com\ethereum\go-ethereum
C:\Users\xxx> go get -u -v golang.org/x/net/context

Finally, the command to compile geth is:

C:\Users\xxx\src\github.com\ethereum\go-ethereum> go install -v ./cmd/...

Create a file genesis.json with like info:

{
"config": {
"chainId": 0,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc": {
"0x744f58fc697a8a0223f16e2ada5b4cb81be5c665": {"balance": "111111111"},
"0x0000000000000000000000000000000000000002": {"balance": "222222222"}
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x1",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}

If you want an address that has balance, first run geth and create a new account, then copy the keystore file and delete the datadir.

Replace the address I have above in genesis.json with your new address, ie. something in place of 0x744f58fc697a8a0223f16e2ada5b4cb81be5c665.

Run:

geth --datadir=ethereum --rpc init genesis.json

Next, ctrl+c to quit, then place your UTC keystore file inside the datadir/keystore

re-run geth:

geth --datadir=ethereum --rpc

Now you'll have balance in that account.

geth attach
web3.fromWei(eth.getBalance(eth.coinbase), "ether")
  • Session 3: Mining locally!

  • Let's mine some Eth!

Now you can mine on that account, set MetaMask or any other wallet to http://localhost:8545 and watch your balance after you import your keystore file!

geth attach
miner.start(1)

(wait for the first DAG to generate on geth)

pic.png

Video Tutorial

Playlist, three sessions:

Sort:  
Loading...

Hey, @hodlorbust!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.07
TRX 0.29
JST 0.047
BTC 67485.59
ETH 2026.82
USDT 1.00
SBD 0.54