Create a private net for Ethereum

GoBlockchain
2 min readMar 20, 2018

This tutorial is for you that had difficulty to create your private net for develop the smart contracts.

Download the geth and mist.

Geth: https://github.com/ethereum/go-ethereum/wiki/geth

Mist: https://github.com/ethereum/mist/releases

Configuration of the geth at .bash_profile

vi ~/.bash_profile #GETH ETHEREUM export GETH_HOME=$HOME/Documents/ferramentas/geth-alltools export PATH=$PATH:$GETH_HOME source ~/.bash_profile

Test your geth GETH OK!!! But this is a public network.

Create the Genesis file:

{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000042",
"difficulty": "0x40000",
"alloc": {
"0x1b143A4D96bDf9AA599850e2bc687e4De28842B5": {
"balance": "10015200000000000000000"
}
},
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0x4c4b40"
}

Inicialize the private net folder

geth --networkid 33333 --port 60303 --rpc --rpcport 8545 --rpccorsdomain "*" --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --minerthreads 1 --datadir $HOME/Library/Ethereum/private init $HOME/Documents/projects/ethereum/CustomGenesis.json

Hey, here you can see the parameters description. https://github.com/ethereumproject/go-ethereum/wiki/Command-Line-Options

Start your private net

geth --datadir $HOME/Library/Ethereum/private

Now open another tab console and start the console of geth(i use 3 tabs of console)

geth attach $HOME/Library/Ethereum/private/geth.ipc

Now we are to create the etherbase for receive the ether of that mining.

the command personal.newAccount() create a new account

Note that account 0x5599bc293af32d7549416781b5fc695bc04023bb was created. Do you can to close the console using “exit”.

Copy the account created and set in etherbase parameter to start the geth(in another tab console or after close the geth console).

geth --networkid 33333 --port 60303 --rpc --rpcport 8545 --rpccorsdomain "*" --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --maxpeers 0 --nodiscover --minerthreads 1 --lightkdf --cache 16 --datadir $HOME/Library/Ethereum/private--mine --etherbase "0x5599bc293af32d7549416781b5fc695bc04023bb"

Now you need to start the Mist using with the parameter the port of this private node, in this case is http://localhost:8545.

Go to new console and digit the address of the installation Mist and start the program with the parameter rpc http://localhost:8545.

/Applications/Ethereum\ Wallet.app/Contents/MacOS/Ethereum\ Wallet--rpc http://localhost:8545

The mist will to open using the PRIVATE-NET!

And do you have in your account the ether necessary to create your smart contracts transactions.

Originally published at https://medium.com on March 20, 2018.

--

--

GoBlockchain

Blockchain, DeFi, dApp, Web3.0, Bitcoin, nova internet