Sunday, June 21, 2015

Ethereum CLI - Go implementation - geth (frontier) installation on Mac

First a few words about the evolution of Ethereum. Alethzero is the current GUI (client) from the cpp (C++) implementation. Mist is the current GUI (client app) from the Go implementation. It used to be called Ethereal. As of right now, the clients do not appear to be ready for prime time. If you want to have access to the blockchain, you have to have a CLI (command line interface). There is a cpp CLI, and there is the Go CLI geth (AKA Frontier). Using geth, you can run commands from your Unix Terminal $ prompt directly, or invoke the JS console and have access to commands from the > prompt. $geth starts the former, and $control-C exits. $geth console starts the latter, and >exit exits. Installation Instructions for geth and Mist. 1. Install Homebrew (http://brew.sh has command-line instructions, install from Terminal) (as brew is installed, you may be prompted to install x-code) 2. $brew tap ethereal/ethereum 3. $brew install ethereal --with-gui Using geth You have to do a few things to make geth work. I like working from the geth console. $geth console >admin.peers() >admin.newAccount() >eth.coinbase >eth.getBalance(eth.coinbase) The peer function must return a list of peers. If it doesn't, something is seriously wrong, like your internet connection is down, or your clock is not synchronized with the network clock. I once started mining without checking this first, and I ended up with a balance of thousands of ethers, but it was invalid because it was mining from block one with no peers. The other three console commands create an ethereum address, assigns it to coinbase if it is the first one, and shows you the balance in the address. The eth functions are a shortcut to the web3.eth API. At this point geth should automatically download the blockchain. This takes many hours. The blocks come in in batches of 256 blocks. You can see your progress by looking at the last block# that came in and comparing it to the current block in existence on etherchain.org. There is a long delay of silence in the console before the blocks start coming in, but usually it tells you that it is about to synchronize with the blockchain before it starts. After that is done, you can mine. >admin.miner.start(2) That tells it to mine with 2 threads. Some CPU's allow 4 threads. As far as I know, right now geth does not support GPU mining directly yet. Before starting mining, the proof of work "DAG" must be downloaded. Starting the miner starts the download. It takes about 15 minutes, and you get a progress status report on this as it comes in. I believe the DAG makes the POW relatively ASIC resistant, at least for now. >admin.hashrate() tells you where you stand, after the DAG is 100% downloaded, and the blockchain is synchronized. Or, instead of mining, you can set up the RPC server using >admin.startRPC(). >admin.progress() also gives useful info.