Getting Started with Ethereum Blockchain and Smart Contract Development
We heard it often: “Blockchain is the next big thing”, “Blockchain has the potential to disrupt a lot of existing industries…”, “Blockchain might have the same impact to our society the internet had in the 90s”.
The best way to find out is to get hands on and see what’s exactly behind it. The most known blockchain by the way is Bitcoin with the first block being created on 2009–01–09. So the basic technology is quite old ;)
This post does not explain the basics of the ethereum blockchain like accounts / wallets, addresses, mining, transactions, smart contracts, gas, wei, gas limit, gas price, balance, proof of work / stake / authority, consensus etc. It is covered very good by the official ethereum whitepaper.
So as first step I decided to install the Ethereum Wallet (0.8.10) on my macOS. This went really easy and straight forward. Starting Ethereum Wallet you can decide if you want to connect to the official PUBLIC-NET or start with TEST-NET. Because my plan was to play around with Smart Contracts I decided to start with the TEST-NET.
After the test blockchain downloaded on my machine my next goal was to look in this “smart contract” stuff. Very soon I realized that some Ether (=ETH) are neccessary in order to deploy a smart contract. Hhhm.
First try — Mining on the TEST-NET
The Ethereum Wallet App integrates a command to start mining on the test-net. After running for about 4 hours my MacBooks temperature was high, by my ETH balance did not move up :(
Second try — Begging for ETH on the TEST-NET
So I searched on the internet if there is a chance to get some ether from nice users on the TEST-NET. And indeed I found http://faucet.ropsten.be:3001/ where you can post your account address, press a button and receive 1 test ether. Cool, but it did not work for me. Tried from time to time but just did not receive any test ether :(
My next internet search led me to https://gitter.im/kovan-testnet/faucet. It is a Chat Channel for exactly what I was looking for. So gave it a try:
Wow. 4 minutes later some one send me 10 ether. I was happy. The transaction was successfull.
Back in the Ethereum Wallet my hope was to see the account balance increase to 10,00 ETH but it just did not happen.
With the “ropsten” “kovan” prefixes in the URLs I already had the feeling that there must be obviously different test nets. (Lesson learned) And indeed — there are currently 3 different test nets (ROPSTEN, KOVAN, RINKEBY). If I only could make Ethereum Wallet App point to the kovan TEST-NET everything would be fine and I could progress my ethereum experience. Unfortunately this is not possible ;) In order to develop on the KOVAN test net you need a different ethereum client — called Parity ;)
Third try — setup a private net
I had no idea how difficult this would be. To my surprise it turned out to be pretty straight forward. I try to be minimal so my goal was to set up the private net with out further downloads etc.
To setup a private net I first needed geth — an ethereum client written in Go language — on the command line PATH. So I tweaked my $HOME/.profile
export PATH="$HOME/Library/Application Support/Ethereum Wallet/binaries/Geth/unpacked:$PATH"
and sourced it
Now starting a private ethereum blockchain is a breath
geth --dev --datadir $ETH_HOME/data --ipcpath $HOME/Library/Ethereum/geth.ipc console 2>>console.log
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
The next thing to do inside geth console is to create an account, start the mining process, watch ethers increasing and checking the blockchain height. Following are some of the used commands inside geth console
> 30000000000000000000 <--- wei = 30e+18 wei = 30 ether
> 30 <--- ether
Because we are pointing the IPC file to Ethereum Wallets default location $HOME/Library/Ethereum/geth.ipc the App connects to the private net blockchain. Tada ;)
Now everything is set up to continue the journey with smart contract and distributed apps development.