Create a new account for private net
$ geth --datadir "~/bether" account new
Create a private chain with the custom genesis block
$ geth --datadir "~/bether" init genesis.json
Launch node zero, a mining full node in cloud
$ geth --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "~/bether" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --identity "zero" --networkid 666 --mine --minerthreads 1 console
To run in background with nohup
$ nohup geth --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "~/bether" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --identity "zero" --networkid 666 --mine --minerthreads 1 > /dev/null &
To run in background with screen
(CTRL+A then D for detaching), check geth.sh
script
$ screen -dmS geth /usr/local/bin/geth --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "~/bether" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --identity "zero" --networkid 666 --mine --minerthreads 1
$ screen -x geth
For attaching geth console
$ geth --datadir "/root/bether" attach ipc:/root/bether/geth.ipc console
Run eth.getBalance(eth.coinbase)
command to check the (pre-allocated) account balance
Run admin.nodeInfo
to get enode url (enode://xxxxx
) and add ip address of the interface [::]
to construct the complete enode address to share with other peers
"enode://6ad5934db83a0266c4c6d5048d02f86b3e69251d45ad411387cde9cc5a86030f2bee4bcbe200d4238d91b01c94444e562986058c9c4acca2a92cb81eb012acfc@192.168.2.41:30303?discport=0"
Setup and launch node one: a non-mining full node
$ geth --datadir "~/bether" account new
$ geth --datadir "~/bether" init genesis.json
$ geth --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "~/bether" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --identity "one" --networkid 666 console
Run admin.addPeer
to connect node zero
> admin.addPeer("enode://6ad5934db83a0266c4c6d5048d02f86b3e69251d45ad411387cde9cc5a86030f2bee4bcbe200d4238d91b01c94444e562986058c9c4acca2a92cb81eb012acfc@192.168.2.41:30303")
Or create a <datadir>/static-nodes.json
file that has the following format
[
"enode://f4642fa65af50cfdea8fa7414a5def7bb7991478b768e296f5e4a54e8b995de102e0ceae2e826f293c481b5325f89be6d207b003382e18a8ecba66fbaf6416c0@33.4.2.1:30303",
"enode://pubkey@ip:port"
]
Send ether from node zero to one using one's wallet address (do not forget to mine if you are the only node mining)
> personal.unlockAccount(eth.coinbase)
> eth.sendTransaction({from:eth.coinbase, to: '0xcb2a95f964acf8adee7fae30cf5dc6a3f5e14a5c', value: web3.toWei(.000000000001, "ether")})
> miner.start()
> miner.stop()
Setup and launch node two: a non-mining light node
$ geth --datadir "~/bether" account new
$ geth --datadir "~/bether" init genesis.json
$ geth --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "~/bether" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --identity "two" --networkid 666 --light console