Saturday, August 22, 2015

Getting Started with Ethereum Using cpp-ethereum

Our previous guides regarding mining and using Ethereum’s Ether (ETH) coins were based on the Go Ethereum implementation (source) as we find it easier to be used than the C++ implementation of the Ethereum client (source) even though we are actually using ethminer for the actual mining which is a part of cpp-ethereum and not go-ethereum package. The Go Ethereum implementation (geth) only comes with built in support for CPU mining, while the C++ implementation (eth) contains support for OpenCL GPU mining both as a part of the client as well as a separate miner (ethminer) and there is also a fork of ethminer with CUDA support available (source).

So now it is time to get started with using the cpp-ethereum (eth) client for creatng a local wallet and for mining both solo on a local system or on an Ethereum mining pool using eth and ethminer. Our guide is for using eth and ethminer on Windows with binaries provided only for that OS (version 0.9.40 64-bit), though the usage should be the same or very similar on other operating systems, but you will need to compile or get binaries for the respective OS. We have tried to make the guide easy and simple to follow, so that you can begin using Ethereum and mining Ether in just a couple of minutes.

cpp-ethereum-getting-started

First we need to create a local wallet and this is the first thing you will do when you run the eth client software. But before that a word of warning, if you have a working geth installation you should know that both Ethereum clients will use the same folder for the blockchain data by default, though the contents of the folder will not be compatible. The key files that are needed for you Ethereum wallet however will be stored in different places and each client will use ts own wallet, but we’ll get back to that in a minute. If you want to have two independently working installations of geth and eth, then you might want to use the --datadir parameter for geth or the --db-path for eth to specify different folder for the blockchain data for one or for both applications.

To generate a wallet with eth:
– Run the provided eth-start.bat file and follow the on screen instructions
– You will be asked to enter a master password, this you need to remember as it will be used to encrypt your wallet and you will be asked the password each time you run the client
– The wallet address you will get will be shown under Transaction signer and Mining Benefactor (marked in red in the screenshot above)
– You can write down that address, just add 0x in front to indicate that it is a hex address foe Ethereum
– Don’t worry, you will be able to get your address listed later on should you not write it down now
– Once the wallet address is generated the client will start to sync the blockchain, this could take some time, especially the first run when there is no data downloaded
– During the first synchronization of the blockchain you might see errors such as DISABLE: Disabling capability ' eth '. Reason: Invalid genesis hash, do not be worried by these, they should stop appearing in a bit

To backup your wallet keys with eth:
– The default datadir for eth is %USERPROFILE%\AppData\Roaming\Ethereum
– However unlike with geth with the eth client the key files are not stored inside the datadir
– You can find the wallet key files inside %USERPROFILE%\AppData\Roaming\Web3\keys
– Just backup the key files and on new installation you can just copy them back to make things work
– Make sure that you remember the password used to encrypt the wallet keys, otherwise you will not be able to access them

ethconsole-commands

With the eth client you would need to run a separate executable in order to get access to the console and be able to type in commands such as to see your wallet address or balance or to send coins to someone. In the geth client for example the console is built in and you can access it if you invoke it through a command line parameter when running the geth client. With the eth client you need to have the client running with eth-start.bat and then you need to run the eth-console.bat to access the console. You should run the console via the provided BAT file instead of directly through ethconsole.exe even though there are no parameters being sent via the batch file, the reason for that is that if you run the EXE file directly you will not be able to copy and paste into the console.

Another difference in the eth client console as opposed to the geth client is that here there are no shortcuts that can save you time when typing commands, you need to type the full commands here in order for the eth console to do what you need. In the screenshot above you can see that we have typed eth.accounts in the console to see the wallet address, but got an error, even though this command works just fine in the geth client’s console. This is because geth has the eth as a shortcut for web3.eth, but using the eth console you need to type the whole thing as there are no shortcuts, so typing web3.eth.accounts will work, the same applies for other commands that use shortcuts that work just fine in the geth client as they will not work directly in the eth console.

Useful console commands for eth:
– To check your account address type in the console: web3.eth.accounts
– To check your account balance type in the console: web3.fromWei(web3.eth.getBalance(web3.eth.coinbase), "ether")
– To send Ether coins to someone type in the console: web3.eth.sendTransaction({from: 'your_address', to: 'recipient_address', value: web3.toWei(1, "ether")})
– In the above line of code make sure to set properly your address and the recipient’s address as well as the value you need to send, in the example above it is set to 1 Ether

Next up is mining with eth and ethminer, if you’ve followed our guides for using geth then you will probably already be familiar with the use of ethminer for solo mining as well as for pool mining. The pool mining part is the same here, but we are going to cover it anyway for the people that are new to using ethminer. The Windows binary package available for download below that you can use to get started contains eth as well as and ethminer for OpenCL and CUDA, do note that you can also use OpenCL on Nvidia GPUs and not only run them in CUDA mode. And while the geth client contains build in mining option that can only use the CPU, the eth client comes with a build in functionality for mining both with the CPU and OpenCL (the same mining functionality that is made available thorugh ethminer).

Getting started solo mining with eth and ethminer:
– First you need to make sure you are running the eth clint with eth-start.bat
– Then you need to run a second instance of eth in mining mode with eth-mine-local.bat
– The above example will work if both instances of eth are running on the same system, if you want to connect multiple miners on different machines to a single eth instance for solo mining you need to enter the ip address of the system running the eth client in the eth miner instances
– You can run ethminer instead of eth for solo mining by just replacing eth with ethminer, the mining command line remains the same for both and when the eth client is running in mining mode it behaves just like ethminer

Getting started pool mining with eth and ethminer:
– You can use the eth client in mining mode for pools as well, just run eth-mine-pool.bat
– To run ethminer mining in OpenCL mode in a pool you can use the provided examples for the currently working pools ethminer-ethpool.bat, ethminer-nanopool.bat, ethminer-ethereumpool.bat

The example BAT files contain the pool information, you will need to enter your wallet address as well as to modify the pool difficulty if the pool supports it (only nanopool does not). Have in mind that currently ethpool is not accepting new miners, so you will need to use some of the other two pools available if you are just starting with mining. You can also check our guides for pool mining with geth and ethminer as well as the other one for solo mining with geth and ethminer if you are interested and decide which one works for you better.

Download eth and ethminer compiled for Windows and ready to be used…

No comments:

Post a Comment