Skip to content

Instantly share code, notes, and snippets.

@Ramarti
Last active November 9, 2017 23:22
Show Gist options
  • Save Ramarti/ec76874e54a48d8c4c1ccb63af566a09 to your computer and use it in GitHub Desktop.
Save Ramarti/ec76874e54a48d8c4c1ccb63af566a09 to your computer and use it in GitHub Desktop.
Steps to geth private network with allocated accounts
{
"config": {
"chainId": <your network id>,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5a04bae4",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x400",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "<your address>",
"alloc": {
"<your address>": {"balance":"9900000000000000000000000000000000000"},
"<your address 2>": {"balance":"100xlambos"}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
#1 Create the account(s) and set password, BEFORE initializing the chain
geth --datadir ./path/to/chaindata/folder account new
#2 Write down the address and change it in genesis.json
#3 Initialize the chain
geth --datadir ./path/to/chaindata init ./path/to/genesis.json
# You should see
#INFO [11-09|23:56:37] Allocated cache and file handles database=/path/to/chaindata/geth/chaindata cache=16 handles=16
#INFO [11-09|23:56:37] Writing custom genesis block
#INFO [11-09|23:56:37] Successfully wrote genesis state database=chaindata hash=4cba80…0e6caa
#INFO [11-09|23:56:37] Allocated cache and file handles database=/path/to/chaindata/geth/lightchaindata cache=16 handles=16
#INFO [11-09|23:56:37] Writing custom genesis block
#INFO [11-09|23:56:37] Successfully wrote genesis state database=lightchaindata
#4 Start geth with rpc enabled so truffle / geth attach can connect
geth --datadir=./path/to/chaindata --rpc --rpccorsdomain "*" --identity "coverage" --port=<port number> --rpcport=<port>
#5 You could connect from other terminal
geth attach ./chaindata/geth.ipc
#6 Check the account(s) have the moneys
balance = web3.fromWei(eth.getBalance(eth.accounts[0]), "ether");
#6 mine to get to byzantium fork block defined in genesis.json
miner.start();
#7 ????
#8 PROFIT!!!
#9 Stop the miner eventually
miner.stop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment