Name: local_ethereum_network
Owner: ConsenSys
Description: Creating a Local Ethereum Blockchain
Forked from: krisrandall/codecave_ethereum_blockchain
Created: 2018-01-05 05:11:23.0
Updated: 2018-01-10 19:29:54.0
Pushed: 2018-01-12 16:51:56.0
Homepage: null
Size: 7
Language: null
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
See also : https://github.com/ethereum/go-ethereum/wiki/Private-network
For windows : https://ethereum.github.io/go-ethereum/downloads/
For a mac :
ew update
ew upgrade
ew tap ethereum/ethereum
ew install ethereum
For linux (Ubuntu)
apt-get install software-properties-common
add-apt-repository -y ppa:ethereum/ethereum
apt-get update
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)
dir <my projects folder>
do ln -s <my projects folder> /projects
dir /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": {}
th --datadir /projects/local_ethereum_blockchain/node1 init /projects/local_ethereum_blockchain/genesis.json
th --datadir /projects/local_ethereum_blockchain/node1 --networkid 1000 console
th --datadir /projects/local_ethereum_blockchain/node-2 init /projects/local_ethereum_blockchain/genesis.json
th --datadir /projects/local_ethereum_blockchain/node-2 --port 30304 --nodiscover --networkid 1000 console
In one geth console :
min.nodeInfo.enode
In the other console :
min.addPeer( <the enode value from the first console> )
min.nodeInfo
Show peers
min.peers
How many peers ?
min.peers.length
You need an account to do be able to do things like mining
rsonal.newAccount()
And make sure your remember/save the password!
Neccessary before some actions
rsonal.unlockAccount( eth.accounts[0] )
ner.start(1)
The first block may take a while to mine, allow a few minutes
ner.stop()
h.blockNumber
h.getBlock( eth.blockNumber )
h.getBlock(eth.blockNumber).miner
b3.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
h.sendTransaction({from: "<from account>", to: "<to account>", value: web3.toWei(1, "ether")})
it
(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>)