It&rsquo,s not effortless for a developer to use Ethereum blockchain, either the main or the testnet network : initial synch takes at least 1 hour and then you&rsquo,ll have to mine some ethers to test anything. So, let&rsquo,s build our own private blockchain to test our wise contracts or Dapps.
Four elements have to be defined for geth or parity to work :
– A Genesis block
– The verkeersopstopping where to store datas
– Few config parameters like de-activation of the «, knot discovery », (recommanded to keep your blockchain private)
Concerning testrpc it&rsquo,s lighter. It simulate a utter client behavior and make developing Ethereum applications much quicker (you don&rsquo,t have to mine blocks and wait 12s for example)
Wij will create our private blockchain with one or several knots using geth or parity, and manage our Ethers and clever contracts with the client Etherereum Wallet
Note : you&rsquo,ll have to know how to use your terminal/console/shell.
Interact with the blockchain
Nevel is a fresh type of browser which aim to launch Dapps (Distributed applications) running on the blockchain. At the time of writing, there are few Dapps available, some wellknown ones are :
Notice that Ethereum Wallet is not a desktop application, it is Nevel configurated to run the Dapp Ethereum Wallet.
Let&rsquo,s begin with Ethereum-Wallet. This app permits you to manage your ethers, exchange them, manage, create and exchange tokens linked with clever contracts and also create clever contracts.
Download and install Ethereum Wallet:
This app contains many apps like geth usable with your shell.
You don&rsquo,t have to launch Ethereum Wallet after downloading it, if you do so, you&rsquo,ll embark synchronising with Homestead or testnet network and use disk space and bandwidth.
A private blockchain with geth
See the geth chapter, otherwise you can use geth provided by Ethereum-Wallet:
1. OS X, druppel Ethereum-Wallet ter /Applications:
Two. Linux or Windows, ter the unzipped verkeersopstopping of Ethereum-Wallet, you&rsquo,ll find a resource directory where geth is :
– open a terminal and define the path
Launch geth te your termnal. Check your version (1.Four ondergrens):
Wij are going to build up several total knots not connected to the P2P network to build our private blockchain. Wij could use several VM or Containers, but spil wij can run at the same time several knots with geth, wij choose this last method which is the easiest and lightest one.
For each geth instruction, wij will define few parameters :
– networkid: Permit you to specify the P2P network. Use a value >, 100 to avoid conflicts. 0: for Olympic 1: for Frontier Two: Morden …
– identity: give your knot a name
– vocht: port mapping mechanism, de-activate by choosing «, none »,
– datadir: permit you to store your knot informatie ter a path you choose
– nodiscover: disables the peer discovery mechanism
So, our Two knots have thesis options :
– –networkid 100 –identity node1 –nodiscover –nat none –datadir=
– –networkid 100 –identity node2 –nodiscover –nat none –datadir=
Create an account for knot 1
Wij need an identity to interact with Ethereum. Wij will use geth :
Give a secure passphrase. Check with your finder that a fresh account has bot created te the directory
Create a Custom-built Genesis block
The blockchain is built upon a very first block called the Genesis block
Wij define this very first block te the opstopping CustomGenesis.json :
Notice that the address 0xedf0e8c867b633d83b10880dbd57c7d64d30a67d will be credited of 1000 ethers originally. Just switch it to your own address.
Wij will now build up the Genesis block with the instruction &lsquo,init&rsquo, and using our CustomGenesis.json opstopping :
This instruction will create the chaindata directory which contains all the blockchain informations defined by geth
Commence knot 1 and commence mining
Once the initial block has bot built, wij just have to embark the knot and begin the mining. On OSX, use the instruction :
Once the DAG created (takes few minutes), mining embark. It works spil a daemon, to zekering it, use Ctrl-C.
Note: Wij have only one 1 miner now. You can check your Ethereum Wallet and you’ll see that you are continuously credited with ethers.
Commence knot Two
To simulate a P2P network, wij will deploy a knot Two. Let’s create the block :
Spil wij do want knot Two to mine, wij need an identity. For simpleness, wij just copy paste knot 1 keystore to knot Two :
/myblockchain/node1/keystore copy ter directory
Wij now have to create a puny script getaddress.geth te which there will be :
Execute it to access knot 1 address (provide the absolute path of the ipc parameter) :
You can spil well read the standard knot 1 output. It’s an address looking like : enode://ec6da5baf0dc2244[email protected][::]:30303
Begin knot Two, and reach the console :
Te a geth console, you’ll find some guidelines like :
Information concerning a knot. Wij will provide knot 1 address’
admin.addPeer(",paste address enode:// spotted earlier",)
If all goes well, this guideline should give you few outputs :
You can then commence mining with this knot :
Use Uitgang or Ctrl-C to interrupt
A private blockchain with Parity
Take a look at the article on parity.
Create an account with Parity
Parity implement can read the accounts defined by geth
To list parity’s account (not those of geth), use the directive line :
Create a fresh account with :
Account informations are stored te
Note: Naming ter parity differ from geth, but internal format are the same.
Create a Genesis block
The blockchain is built upon a very first block called the Genesis block. Spil with geth, this very first block is defined ter genesis_parity.json :
The chain pamameter is used to specify the name of the blockchain :
* olympic, frontier, homestead, mainnet, morden, or testnet are public Ethereum blockchain
* path to the Custom-built Genesis opstopping of our private blockchain
For our private blockchain, wij add this option : –chain path/genesis_parity.json to the parity directions.
Note: This format gives more possibility than geth.
Execute knot 1
Wij will use the same genesis_parity.json verkeersopstopping for all knots. Wij can use identity to name each knot. Define ipcpath if you want to use Ethereum Wallet. Define –author to specify your coinbase address (the recipient of the mining prize)
Once the DAG created (takes a few minutes), mining embark spil a daemon. Interrupt it with Ctrl-C.
Save your knot url enode://[email protected]:30303 to connect with knot Two
Note: One knot is running now. Run your Ethereum Wallet and check that you are connected to your private network.
Parity doesn’t provide mining option yet. Use ethminer fromm cpp-ethereum to enable it :
Execute knot Two
For knot Two to interact with knot 1 on the same device, wij will have to switch few ports and ipc path :
To run a miner on this knot, you’ll have to specify the address :
It’s a nodejs software. Once nodejs installed on your OS :
Written by Laurent Mallet &, Regis Pietraszewski