Ethereum mist mining
We are going to use Ethereum for understanding how to create and use Smart contracts. Like any environment, Ethereum also comes with its own tools. Mist and Geth are the two most important tools that you must be comfortable with.
As we discussed in Part 0a blockchain is nothing but a distributed ledger. This ledger is distributed over numerous nodes that are always in sync. To connect to the network we need a tool. One such official tool is Mist. Mist is a wallet. It allows you to not only store your ether cryptocurrency but also allows you to send and receive ether from other persons.
There is another very important feature of Mist. Mist also allows you to create and execute Smart Contracts. Hence Mist is going to be an important tool for our journey into Smart Contracts. When you start Mist, it will connect to Main Network by default. By starting Mist you will become part of Blockchain which means you also need to have a copy of the ledger.
The first time you start Mist, it will synchronize itself. This could even take days as the data is already in many GBs now. Therefore it makes sense to start Mist in test network if your only purpose is to test it out. Although it will be fewer data to download it will still take some time to synchronize with test network.
Once you have downloaded Geth and installed it. Run the following command on terminal 1 geth --dev --rpc --mine. Geth is the executable file. Else you can go to the directory that has these files and execute from that directory on a terminal.
Here --dev flag starts the geth in development mode creating a private network. Since we are starting on local machine a new instance, our CPU will be fine to mine some Ethereum coins for us. We will need these coins to continue our workflow. One Geth starts, execute the Mist wallet. Make sure when you start, Mist is connecting to your server. There will a text saying Private Net on splash screen while starting Mist.
In case there is any issue you can start Mist by calling its executable with --rpc http: Now you have Geth and Mist running. Inside Mist, click on the Add Account button. You will be asked for a password. Choose a password for this account.
The reason Main Account has ether is that we started geth with --mine command which is mining Ether for us. Please remember this not real Ether as we are not on the Main network.
Click on the send button on the top bar and enter the address of the newly created account. Enter the amount and send it. You have done your first transaction. There is one very helpful feature for Geth and that is its console. You can start the console using the following command in new terminal 1 geth attach.
In such case, start geth without mining i. In console, use following to get list of all accounts 1 personal. You can create new accounts with 1 personal. To get balance, use 1 eth. As you can see, we have to download and setup Geth. Then create a base account and add Ether by mining. Then we can create more accounts and send ether to them. All this can be done more easily by using testrpc. It creates a base account and other accounts for you and put some ether into it saving your time.
To install testrpc you will need to have Node. Once you have it install testrpc using 1 npm install -g ethereumjs-testrpc. If you are on Mac or Linux, you might need sudo rights. Once installed you can start it by simply running it in terminal 1 testrpc. TestRPC will be more useful when we get into the more programmatic approach. In next part, we will create our first Smart Contract.
You can check it out here. There are 3 types of networks, Mist or any other Ethereum client can connect to. Main Network This is the network that is publically accessible to all and all real transactions happen here. It is the main blockchain where you need to be, to access ether and do real transactions. That will be wastage of real resources. Therefore there are certain networks available whose sole purpose is to be used as test network. Private Network You can create your own private network or connect to an independent private blockchain.