Skip to content

Instantly share code, notes, and snippets.

@mritzco
Last active May 11, 2018 15:09
Show Gist options
  • Save mritzco/31d837d8249c2e14f5aeb8fe4fb72bc9 to your computer and use it in GitHub Desktop.
Save mritzco/31d837d8249c2e14f5aeb8fe4fb72bc9 to your computer and use it in GitHub Desktop.
Starting and using a private ethereum blockhain

Running your own private blockchain and connecting to it.

1. Start bootnode and private network

Go to wherever you want to run this.

  mkdir privatechain
  cd privatechain/
  
  touch genesis.json 
  mkdir data

2. Edit genesis.json (check next file)

3. Run bootnode

bootnode --genkey=boot.key
bootnode --nodekey=boot.key
  • Copy the info and replace in the next step

4. Start geth, from the same directory where we were in #1

 geth --datadir="data_directory_from_step_1" init genesis.json
 geth --bootnodes="enode_info_from_step_3@your_ip_public_or_private:30301" --verbosity=6 console

Example:

geth --datadir="/home/itzco/Tech/blockchain/privatechain/data" init genesis.json
  geth --bootnodes="enode://518a1f2661a344b2c6d5a2f618e3763110a224c47b7fcdf5fc78925dbf2807e3abaad136bbb7db67fe601f839e04bf2dc7d746aca773214b9b9b41bd7f25bbc3@192.168.8.57:30301" --verbosity=6 console

Connecting to your private network

....

Notes

Seems to work with remote servers via public IP. Failed after a while with sync issues:

###References: Instaling ethereum on ubuntu or docker

Main reference for private network

Secondary:

Getting your public IP address

Connecting to your private network with mist

# In the directory of your choice
mkdir privatechain
cd privatechain/
touch genesis.json
mkdir data
bootnode --genkey=boot.key
bootnode --nodekey=boot.key
# Edit your genesis.json
geth --datadir="your_directory_from_line_5" init genesis.json
geth --bootnodes="result_from_line_7_replace_your_ip" --verbosity=6 console
{
"config": {
"chainId": 0,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment