Mining - Go Ethereum
Mining - Go Ethereum
Getting Started
Mining
Install and Build
This document explains how to set up geth for mining. The Ethereum wiki also has a page about mining, be sure to check that one
as well.
Using Geth Mining is the process through which new blocks are created. Geth actually creates new blocks all the time, but these blocks need
to be secured through proof-of-work so they will be accepted by other nodes. Mining is all about creating these proof-of-work
Command-line Options values.
The proof-of-work computation can be performed in multiple ways. Geth includes a CPU miner, which does mining within the geth
Connecting To The Network
process. We discourage using the CPU miner with the Ethereum mainnet. If you want to mine real ether, use GPU mining. Your best
option for doing that is the ethminer software.
JavaScript Console
Always ensure your blockchain is fully synchronised with the chain before starting to mine, otherwise you will not be mining on the
Managing Your Accounts correct chain and your block rewards will not be valueable.
Mining
Private Networks
GPU mining
The ethash algorithm is memory hard and in order to t the DAG into memory, it needs 1-2GB of RAM on each GPU. If you get
FAQ
Error GPU mining. GPU memory fragmentation? you don’t have enough memory.
Metrics
Installing ethminer
For dApp Developers
To get ethminer, you need to install the ethminer binary package or build it from source. See https://github.com/ethereum-
mining/ethminer/#build for the of cial ethminer build/install instructions. At the time of writing, ethminer only provides a binary
JSON RPC APIs for Microsoft Windows.
Whisper Follow the prompts and enter a good password. DO NOT FORGET YOUR PASSWORD. Also take note of the public Ethereum
address which is printed at the end of the account creation process. In the following examples, we will use
0xC95767AC46EA2A9162F0734651d6cF17e5BfcF10 as the example address.
Vulnerabilities
Now start geth and wait for it to sync the blockchain. This will take quite a while.
Now we’re ready to start mining. In a new terminal session, run ethminer and connect it to geth:
ethminer -G -P http://127.0.0.1:8545
ethminer communicates with geth on port 8545 (the default RPC port in geth). You can change this by giving the --rpcport
option to geth . Ethminer will nd get on any port. You also need to set the port on ethminer with -P http://127.0.0.1:3301 .
Setting up custom ports is necessary if you want several instances mining on the same computer. If you are testing on a private
cluster, we recommend you use CPU mining instead.
If the default for ethminer does not work try to specify the OpenCL device with: --opencl-device X where X is 0, 1, 2, etc. When
running ethminer with -M (benchmark), you should see something like:
Benchmarking on platform: { "platform": "NVIDIA CUDA", "device": "GeForce GTX 750 Ti", "version": "OpenCL 1.1
Benchmarking on platform: { "platform": "Apple", "device": "Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz", "vers
Note hashrate info is not available in geth when GPU mining. Check your hashrate with ethminer , miner.hashrate will always
report 0.
You can also start and stop CPU mining at runtime using the console. miner.start takes an optional parameter for the number of
miner threads.
> miner.start(8)
true
> miner.stop()
true
Note that mining for real ether only makes sense if you are in sync with the network (since you mine on top of the consensus block).
Therefore the eth blockchain downloader/synchroniser will delay mining until syncing is complete, and after that mining
automatically starts unless you cancel your intention with miner.stop() .
In order to earn ether you must have your etherbase (or coinbase) address set. This etherbase defaults to your primary account. If
you don’t have an etherbase address, then geth --mine will not start up.
> miner.setEtherbase(eth.accounts[2])
Note that your etherbase does not need to be an address of a local account, just an existing one.
There is an option to add extra data (32 bytes only) to your mined blocks. By convention this is interpreted as a unicode string, so
you can set your short vanity tag.
> miner.setExtra("ΞTHΞЯSPHΞЯΞ")
You can check your hashrate with miner.hashrate, the result is in H/s (Hash operations per second).
> eth.hashrate
712000
After you successfully mined some blocks, you can check the ether balance of your etherbase account. Now assuming your
etherbase is a local account:
> eth.getBalance(eth.coinbase).toNumber();
'34698870000000'
You can check which blocks are mined by a particular miner (address) with the following code snippet on the console:
Note that it will happen often that you nd a block yet it never makes it to the canonical chain. This means when you locally include
your mined block, the current state will show the mining reward credited to your account, however, after a while, the better chain
is discovered and we switch to a chain in which your block is not included and therefore no mining reward is credited. Therefore it
is quite possible that as a miner monitoring their coinbase balance will nd that it may uctuate quite a bit.
The logs show locally mined blocks con rmed after 5 blocks. At the moment you may nd it easier and faster to generate the list of
your mined blocks from these logs.