See also : https://github.com/ethereum/go-ethereum/wiki/Private-network
For windows : https://ethereum.github.io/go-ethereum/downloads/
For a mac :
$ brew update
$ brew upgrade
$ brew tap ethereum/ethereum
$ brew install ethereum
For linux (Ubuntu)
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
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
$ mkdir /projects/local_ethereum_blockchain
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": {}
}
$ geth --datadir /projects/local_ethereum_blockchain/node1 init /projects/local_ethereum_blockchain/genesis.json
$ geth --datadir /projects/local_ethereum_blockchain/node1 --networkid 1000 console
$ geth --datadir /projects/local_ethereum_blockchain/node-2 init /projects/local_ethereum_blockchain/genesis.json
$ geth --datadir /projects/local_ethereum_blockchain/node-2 --port 30304 --nodiscover --networkid 1000 console
In one geth console :
> admin.nodeInfo.enode
In the other console :
> admin.addPeer( <the enode value from the first console> )
> admin.nodeInfo
Show peers
> admin.peers
How many peers ?
> admin.peers.length
You need an account to do be able to do things like mining
> personal.newAccount()
And make sure your remember/save the password!
Neccessary before some actions
> personal.unlockAccount( eth.accounts[0] )
> miner.start(1)
The first block may take a while to mine, allow a few minutes
> miner.stop()
> eth.blockNumber
> eth.getBlock( eth.blockNumber )
> eth.getBlock(eth.blockNumber).miner
> web3.fromWei(eth.getBalance(eth.accounts[0]))
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
> eth.sendTransaction({from: "<from account>", to: "<to account>", value: web3.toWei(1, "ether")})
> exit
(This will also stop the node from running if it was started using $ geth console
(as opposed to $ geth attach
))
-
Get the IP of the node :
$ ifconfig|grep netmask|awk '{print $2}'
-
Get the enode of the node :
> admin.nodeInfo.enode
-
REPLACE
[::]
in the enode string with the[<ip address>]
-
On your console
> admin.addPeer(< the enode string with the ip address in it>)