Ethereum – Introduction For Software Developers

Poloniex ETH/BTC 1m chart. 0.00644 BTC to 0.0235 BTC = 264% increase. Peak 0.0310 BTC = 381% increase.

Poloniex ETH/BTC 1m chart. 0.00644 BTC to 0.0235 BTC = +264%. Peak 0.0310 BTC = +381%.

I was talking to a colleague this morning and he was quite excited over the ETH/USDT chart on the main Ethereum exchange Poloniex, drawing imaginary lines while describing his trading strategies for ethers, include options positions. But he had not looked into using the Ethereum blockchain yet – fundamental analysis rather than technical analysis. I suggested to my colleague that he first test runs the Ethereum technology before planning his advanced trading strategy. So, here is a short introduction to the Ethereum blockchain for him, a software developer not yet familiar with blockchains, and maybe you. I would like to show you how Ethereum is more than just a cryptocurrency – it is a world computer that will execute your programs on it’s trusted blockchain network (in the next part).

This guide only shows an example of CPU mining on the main Ethereum network (Mainnet). CPU mining is very inefficient compared to the thousands of mining rigs on the Ethereum network mainly running GPUs (Graphics Processing Units). This guide then shows you how to perform some transactions on the Dev blockchain, which only runs on your local computer.

You can run the examples below on most Windows, Mac or Linux computers, servers, desktops or notebooks. No GPUs required.

You’ve got nothing to lose trying out these examples, except for software installation bloat,  ~ 10.5 Gb of disk space for the Ethereum blockchain plus the DAG file which is use in the mining process, the 10.5 Gb downloaded via your broadband connection, and time. So give it a go. You can always delete any unwanted files later.


Featured Mining Photo

Figure 17: Lizard Cannell filling the drilled holes with light explosives. Photo by Karen Black.

No blockchains. Just chains of red cord so the shockwave acts together in one rock-splitting moment. Lizard mining for fossils at Riversleigh with light explosives. Photo by Dr. K. Black.

 


Table of contents


Resources

See Ethereum Resources.


Installation

Install the Ethereum Go client using the instructions above for you operating system. I’ll be using Ubuntu Linux for the rest of this post, but the operations should be similar in Windows or Mac.


Create An Account

Run the command and enter a password that will be used to encrypt our private key. Store this password in a safe place. The generated address(or account) is your Ethereum public key. The first and default account is also called the coinbase.

Your private key is stored in ~/.ethereum/keystore and will require your password to unlock before use.


Run The Ethereum Node Client On Mainnet

This next step will take quite some time if this is the first time you are starting the Ethereum client, as the client will have to connect to peers and download the existing blockchain data (~ 9.7 Gb @ 07/03/2016). You can skip this step if you want to just try out the Dev blockchain, and come back later to this step to perform the blockchain synchronisation.

Start The Client

Some Handy Commands

The commands ‘eth’ and ‘web3’ will list some of the commands that may be useful. Further information available at https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console and https://github.com/ethereum/wiki/wiki/JavaScript-API. Hint – you can type ‘eth.<Tab>’ and geth will show you the list of valid commands. For example:

Try out a few commands, e.g., ‘eth.accounts’, ‘eth.block number’, ‘web3.admin.peers’. As you have no ethers in your account, you have nothing to lose.

Listing Peers

The next command will list the peers your Ethereum Go client is connected to.

Listing The Transaction Pool

This one will show you the contents of the transaction pool:

Check The Number Of Ethers In Your Account

The following command will show you the ethers in your coinbase (default account/address), which should be 0 if you have not mined any ethers yet:

Check The Number Of Ethers In Poloniex’s Coldwallet

The following command will show you the ethers in the Poloniex Coldwallet (I got the address from https://etherscan.io/accounts/a:

Yup. That’s about AUD 147,811,199 at an ETH/AUD rate of 13.84 or about 14% of the 77,577,320 available supply of ethers. This amount includes the ethers on orders, ethers waiting to be traded, ethers waiting to be transferred out to people’s personal accounts (addresses), and Poloniex’s reserves + profits.

Start CPU Mining

This step will require that the Go client complete the downloading of the blockchain, so you will only be able to run this successfully after many hours. Again, note that CPU mining is quite inefficient to GPU mining (which is not covered in this post). At any time, you can press <Control>-C to stop the command.

The parameter to miner.start() is the number of CPUs to allocate to the mining process. A DAG file will firstly be generated as this is required for the mining operation. This DAG file will be stored in your ~/.ethash subdirectory, and is currently about 1.3 Gb in size.

You will notice that your CPU will be running at a higher rate than normal during this mining process. The miner.hashrate function is not working in my Go client, so I won’t demonstrate it here.

From previous tests, my Intel Core i7 laptop CPU mines at a hashrate of ~ 425,000 hashes per second. Each of my AMD R9 390X GPUs mine at a hashrate of ~ 31,000,000 hashes per second, ~ 72x faster. And the network hashrate is currently 919,100,000,000 hashes per second and increasing – equivalent to 30,000x my GPU’s hash rate.

Stop CPU Mining

You can stop the miner using the following command:

Exiting The Client

Press <Control>-D to exit the client:


Run The Ethereum Node Client In Dev Mode

In this section, we will create a second account, start the miner on the Dev blockchain (on your local computer only). The mining process will mine some ethers into your first account, and you can then create a transaction to send some of these ethers into your second account. We can then check the balances.

Note – while the accounts created are the same in Mainnet and your Dev blockchain, the amount of ethers in your Mainnet account won’t be affected by changes done when mining on the Dev blockchain. Unfortunately you cannot mine ethers on the Dev blockchain and get them to show up in your Mainnet accounts.

Create Second Account

Start The Client In Dev Mode

Note that as we are going to send a transaction from the first account (eth.accounts[0]), we will have to unlock the account when we start the client. This is done by adding ‘–unlock 0’ in the command line, then entering the original password we used when creating the account.

Check The Number Of Ethers In Your Coinbase

On the Dev blockchain, you start off with a zero balance in your main account.

Start Mining The Dev Blockchain

Start mining the Dev blockchain and you will receive an unlimited number of 5 ethers per block mined.

Check The Number Of Ethers In Your Coinbase Again

Your account should contain 5 x number of blocks you have mined.

Check And Transfer Ethers To Your Second Account

Check the amount in your second account. Note the [0] has been changed to [1] in the command below.

We will then run ‘eth.sendTransaction’ to send some ethers from the first account to the second account.

Check the amount in your second account. It should contain the amount transferred. Note that the first account would will go down by this transferred amount and a transaction fee.

Line #4 above contains the transaction hash “0x09b77a07a6a8b5076a8b03c7dcf578ce7dd937796c8d57821fc916ba15800163”. You can use the following command to view the details of the transaction. If you can run this command before the transaction is included into a mined block, you will see blockNumber is null.

Run the same command after the block is mined and you will see that the blockNumber now has a value.

The value of 10234000000000000000 above can be plugged into  http://ether.fund/tool/converter to show that this number of weis is equivalent to 10.234 ethers:EtherFund_20160308_094929

Look at the block details using the following command and you will see the transaction hash on line #19. The miner field on line #9 is your coinbase address since we are self-mining on this Dev blockchain. You can find the details of the latest block using ‘eth.getBlock(“latest”)’.

Take the parent hash from line #12 above and run ‘eth.getBlock(“0x6712df19272baa4834309fc8976dd98fc72e1f80936c9e2f5035ded6f52b624c”)’ and you will see the details of block number #61. Block #62 is built upon block #61 and the hash of the parent #61 is included in the hash calculations of block #62 to verify the integrity of the blockchain.

Stop Mining And Exit

Run the miner.stop(1) command then press <Control>-D to exit the client.


This is the end of this post. I’ll post some instructions on running smart contracts in my next post in this series.

Enjoy.

Bokky Poo Bah, the ninth King Of The Ether Throne, the Ninth of His Name, the Uncentralized, Sovereign of the Exalted Order of Miners, Emperor of the Blocks beyond the Sidechains, Head of the Great Patricia Tree.

07/03/2016.

This entry was posted in Cryptocurrency and tagged , , . Bookmark the permalink.

Leave a Reply