Ethereum Tutorials

Setting up Private Block Chain

When it comes to choosing the development environment for writing smart contracts, there are almost too many options available. We are going to choose Geth + Mist, note that in almost any area of software development, one need to draw a line at some point, stating "these are tools I am going to use". There are Eth, MetaMask, Truffle... We are going to use a minimalistic set, that's all. In other words, I can not prove that my choice is any better than other possible choices.

First of all, download Mist from Github, unless you have other sources. Remember, I mentioned that there is certain mess in the area? Here is an example: at the moment of this writing Mist folks offer Mist and Ethereum Wallet, on the same site, not explaining what the difference is. You will have to Google out the answer: you need Mist, as it has tools to work with contracts, while Ethereum Wallet is just a wallet.

Installation is trivial, you can simply unzip the folder. Then the fun begins: When you start Mist, it downloads the Geth. It does so silently, and you need some more googling to figure out (I use Windows as an example) that it went to "C:\users\john\appdata\roaming\mist\binaries\geth\unpacked\geth.exe" (here the "John" part of the path might vary :)

Anyway, stop Mist few seconds after you started it: it will download the Geth and it will also try to download the block chain - which you do not need.

Click (again - in Windows) CTRL-ESC to open the start menu, and run the command prompt. Copy and paste the following command, edit the path though:

"C:\users\john\appdata\roaming\mist\binaries\geth\unpacked\geth.exe" --datadir=C:\Archive\Bitcoins\eth_private_data --dev --networkid 42 --nodiscover --rpc --rpccorsdomain "*" --rpcapi="db,eth,net,web3,personal,web3"

This will start Geth in the private block chain mode with few developers options turned on.

Start Mist. Now as Geth is running, Mist will attach to it, instead of starting another Geth with different settings.

By now, the Geth emulates the block chain, and Mist works as a wrapper, providing us with graphical UI. What we need now is a SECOND Geth, running attached to the first one: we will run a Java Script console in it.

Start a second Geth in a second Command Prompt window by executing the following command:

"C:\users\john\appdata\roaming\mist\binaries\geth\unpacked\geth.exe" --datadir=C:\Archive\Bitcoins\eth_private_data --dev attach

That's it, our environment is up and running.

For our tutorial, we are going to need two accounts, so let's create them:

From Mist, select Accounts - New, enter a password (as this is a testing environment, we can use a simple "password"). Create two accounts.

Now we need some money (toy money, as this is a testing environment) on our accounts. Go to the Geth console (one we started SECOND) and run


The amount of ether in Mist will go up. Wait few seconds and type:


As you may have noticed, only the first of our two accounts have receiced the money. To put some money on the second account, you can click "transfer funds" icon in Mist. Note that funds can only be transfered when miner is on, so turn it on after transaction is sent, and then turn it off again.

Note that in order to work in the "real" network, you need something like this:

In first command prompt window:

"C:\users\john\appdata\roaming\mist\binaries\geth\unpacked\geth.exe" --datadir=C:\Archive\Bitcoins\eth_real_data --syncmode="light"

In second command prompt window:

"C:\users\john\appdata\roaming\mist\binaries\geth\unpacked\geth.exe" --datadir=C:\Archive\Bitcoins\eth_real_data --dev attach

I am going to explain the --datadir flag in the next chapter.

Visibility is very important for this site. If you like it please link from your page to this URL or share info using Social Buttons below.
(C), all rights reserved

Please read the disclaimer