Local OJX Network

See also : https://github.com/ethereum/go-ethereum/wiki/Private-network

Setting up your OJX Node(s)

1. Prereq : Install Geth

Review the guide here

2. Prereq : create /projects

Create a /projects symbolic link (Note: This step is simply so "/projects" can be used in all other commands, instead you could use full paths, or set an env var)

$ mkdir <my projects folder>
$ sudo ln -s <my projects folder> /projects

3. Create local_ethereum_blockchain folder

$ mkdir /projects/local_ethereum_blockchain

4. Create the genesis block config

Create this file : /projects/local_ethereum_blockchain/genesis.json

With the following contents :

{
     "config": {
       "chainId": 1000,
       "homesteadBlock": 0,
       "eip155Block": 0,
       "eip158Block": 0
                },
     "nonce": "0x0000000000000061",
     "timestamp": "0x0",
     "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
     "gasLimit": "0x8000000",
     "difficulty": "0x100",
     "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
     "coinbase": "0x3333333333333333333333333333333333333333",
     "alloc": {}
}

(info about the genesis file)

5. Initialise an Ethereum node

6. Start that Ethereum node

7. Initialise another Ethereum node

8. Start the 2nd Ethereum node

9. Connect one node to the other

In one geth console :

In the other console :

Useful geth commands

Node info

Peers

Show peers

How many peers ?

Create an account

You need an account to do be able to do things like mining

And make sure your remember/save the password!

Unlock account

Neccessary before some actions

Start mining

The first block may take a while to mine, allow a few minutes

Stop mining

Current block number

Details of current block

Which node minded the last block

Account balance, in ether

Transfer ether between accounts

First get the account numbers by doing

> eth.accounts

Then unlock the account you are sending from

> personal.unlockAccount( <from account> )

eg.

> personal.unlockAccount(eth.accounts[0])

Finally transfer 1 ether

Exit

(This will also stop the node from running if it was started using $ geth console (as opposed to $ geth attach))

Connect to other nodes on your network

  1. Get the IP of the node : $ ifconfig|grep netmask|awk '{print $2}'

  2. Get the enode of the node : > admin.nodeInfo.enode

  3. REPLACE [::] in the enode string with the [<ip address>]

  4. On your console > admin.addPeer(< the enode string with the ip address in it>)

Last updated