Ethereum
Ethereum is a next-generation peer-to-peer blockchain-based technology platform. It supports smart contracts and provides a platform for distributed applications.
Ethereum Clients
There are multiple ethereum clients that implement the ethereum protocol. The
leading implementations are the clients go-ethereum
and Parity
.
The go-based go-ethereum
client is developed by the Ethereum Foundation,
while the rust-based Parity client is developed by Parity Technologies.
For more details about the different clients have a look at the ethdocs.org wiki.
Ethereum wallet
In most cases users don't want to run CLI-based programs such as geth
. Instead,
they want to run a UX-friendly applications that allows them to manage their ethereum
accounts.
For this case, these users can use the Mist browser.
The latter is a tool to browse and use distributed applications or for short Dapps.
The Ethereum Wallet is basically an Electron-based application and a Dapp,
which runs in the background the go-ethereum
client.
go-ethereum aka geth
The go-ethereum client,
which is also knwon as geth
, is the the command line
interface for running managing a full ethereum node. As the name indicates,
geth is written using the Go programming language.
Users that install and run geth, can take part in the ethereum live network.
Moreover, they can do the following things using geth
:
- mine real ether using the integrated CPU miner
- transfer funds between addresses
- create contracts and send transactions
- explore blockchain history
Installation
On Arch Linux geth
can be installed using the command below:
pacman -S geth
On Ubuntu, we can use the PPA ethereum/ethereum
to install geth
:
apt-get install software-properties-common
add-apt-repository -y ppa:ethereum/ethereum
apt-get update
apt-get install ethereum
CLI Overview
The following table provides a short overview of all the commands that the geth
client supports.
Command | Description |
---|---|
bug | Opens a window to report a bug on the geth repo |
console | Start an interactive JavaScript environment |
copydb | Create a local chain from a target chaindata folder |
dump | Dump a specific block from storage |
dumpconfig | Show configuration values |
export | Export blockchain into file |
import | Import a blockchain file |
init | Bootstrap and initialize a new genesis block |
js | Execute the specified JavaScript files |
license | Display license information |
makecache | Generate ethash verification cache (for testing) |
makedag | Generate ethash mining DAG (for testing) |
monitor | Monitor and visualize node metrics |
removedb | Remove blockchain and state databases |
version | Print version numbers |
wallet | Manage Ethereum presale wallets |
help, h | Shows a list of commands or help for one command |
Blockchain Management
Sometimes the internal database formats need to be updated. This can be done with the following command:
geth upgradedb
Geth's blockchain and state databases can be removed with:
geth removedb
This is useful for deleting an old chain and sync'ing to a new one. It only affects data directories that can be re-created on synchronisation and does not touch the keystore.
Account Management
Ethereum account are managed using the subcommand geth account
. With the help
of this command, you can create, list, update accounts and import private keys
into a new account.
Please remember that if you lose the password to encrypt your account, you will not be able to access that account again. Thus, do not forget the password and to backup your account keystore files.
The default data directory on Linux is ~/.ethereum. However,
you change the location of the data directory by specifying the --datadir parameter.
Per default the private keys are stored under ~/.ethereum/keystore
.
Command | Description |
---|---|
geth account new | Create account |
geth account list | List accounts |
geth account update | Update an existing account |
geth account import | Import a private key into a new account |
geth account help | Shows help for the command |
Moreover, you can use the following options to unlock accounts.
ACCOUNT OPTIONS:
--unlock value Comma separated list of accounts to unlock
--password value Password file to use for non-interactive password input
Usage examples
Create a new account:
geth account new
List accounts:
geth account list
Import private key:
geth --datadir /someOtherEthDataDir account import ./key.prv
Update an existing account:
geth account update xyz
CPU Mining
geth
supports CPU mining, however, it is not advised to use CPU mining as it's not
an effcient way to mine. For mining use a GPU-based miner such as ethminer.
Nevertheless, CPU mining is handy in case you want to test thing or setup a private blockchain or ethereum testbed.
For example the command below starts the cpu miner, which is part of geth
:
geth --mine --minerthreads 4 --etherbase xyz
Note: these options have the following meanings:
--mine Enable mining
--minerthreads value Number of CPU threads to use for mining (default: 4)
--etherbase value Public address for block mining rewards (default = first account created) (default: "0")
Ethereum full node
In order to run a full Ethereum node, we need to launch geth
:
geth --fast --cache 2048 2> geth.log
In case you want to run a full Ethereum node with remote rpc access, you can run geth as follows:
geth --rpc --rpcaddr 0.0.0.0 --rpcapi --wsapi 2> geth.log
Here we indicate geth to use the network address 0.0.0.0
and to enable rpc API over HTTP
as well as the API over the websockets protocol.
To increase the synchronization process we can pass the option --syncmode fast
and we can increase the memory cache size, where the synchronized blocks are first written
to the memory.
geth --rpc --rpcaddr 0.0.0.0 --rpcapi --wsapi --syncmode fast --cache 2048 2> geth.log
Interactive console
Once a geth instance is running, we can access an interactive JavaScript console by running the following command:
geth attach
Account Management
Once we have access to an interactive console, we can play around with Ethereum.
A new account can be created using the personal
object:
personal.newAccount()
With the eth
object we can get a list of the ethereum accounts on the current system:
eth.accounts
To check the balance of an account, we can use the following code snippet:
s = '0x...'
web3.fromWei(eth.getBalance(s), "ether")
Checking Connectivity
net.listening
net.peerCount
admin.peers
GPU Mining: ethminer
ethminer is an open source Ethereum miner with OpenCL, CUDA and stratum support. It is written in C++ and is actively maintained by the Ethereum community. The code base originates from the cpp-ethereum project where GPU mining has been discontinued.
Thanks to the stratum support, ethminer can be easily used and set up with ethereum mining pools such as ethermine.org or nanopool.org.
Installation from source
This section shows how ethminer can be installed from source on Ubuntu.
First, install the necessary dependencies:
sudo apt install build-essential git cmake golang-go
Second, git clone the repo from github using git
:
git clone https://github.com/ethereum-mining/ethminer
Third, build the project using the listed commands below:
cd ethminer
mkdir build; cd build
cmake ..
cmake --build
Finally, install the binary:
make install
To double check if the miner works, run the command below, which should print the version number:
ethminer --version
CLI
Options | Description |
---|---|
--version, -V |
Show version |
-G, --opencl |
Use GPU mining |
-Z [<n>],--simulation [<n>] |
Simulation mode |
-M [<n>],--benchmark [<n>] |
Benchmark for mining |
--list-devices |
List the detected OpenCL/CUDA devices and exit |
--opencl-device <n> |
Use the OpenCL devices <n> |
--opencl-platform <n> |
Use the OpenCL platform <n> |
Usage examples
List the detected OpenCL/CUDA devices and exit.
ethminer --list-devices
Benchmark the OpenCL device 0:
ethminer -M -G --opencl-device 0
Benchmark the OpenCL platform 0:
ethminer -M -G --opencl-platform 0
Simulate mining on the OpenCL device 0:
ethminer -Z -G --opencl-device 0
Simulate mining test on the OpenCL platform 0:
ethminer -Z -G --opencl-platform 0
GPU Mining Script
The listed bash script below can be used to start ethminer
. Change the variable
ADDRESS
to your ethereum wallet address and change the variables S_POOL
and FS_POOL
to your preferred mining pool.
#/usr/bin/env bash
ADDRESS="..."
S_POOL="eu1.ethermine.org:4444" # Main mining pool
FS_POOL="us1.ethermine.org:4444" # Failover mining pool
ethminer --report-hashrate --farm-recheck 200 --opencl -S $S_POOL -FS $FS_POOL \
-O ${ADDRESS}.${WORKER}
Mist
Mist allows users to browse and use Ðapps on the Ethereum network.
For installing Mist, we need to download the latest release from the Mist github page: https://github.com/ethereum/mist/releases
In order to install the Ethereum Wallt on Linux, download the zip file Ethereum-Wallet-linux64-0-9-3.zip via wget:
wget https://github.com/ethereum/mist/releases/download/v0.9.3/Ethereum-Wallet-linux64-0-9-3.zip
Next, double check the sha256sum of the downloaded zip file. The sha256sum must
match the sha256 hash bacff5b9ca62b43d38234059ec73f75ef076f97da1e96a8d4f5dbc3b3f17ad69
,
otherwise the zip file is not trustworthy.
sha256sum Ethereum-Wallet-linux64-0-9-3.zip
bacff5b9ca62b43d38234059ec73f75ef076f97da1e96a8d4f5dbc3b3f17ad69 Ethereum-Wallet-linux64-0-9-3.zip
Next, unzip the zip file:
unzip Ethereum-Wallet-linux64-0-9-3.zip
Once unpacked, move the contents to the /opt
directory and adjust the $PATH
variable in your .bashrc
or .zshrc
config to include the path /opt/ethereum-wallet-mist/
:
mv linux-unpacked /opt/ethereum-wallet-mist
echo 'export PATH="$PATH:/opt/ethereum-wallet-mist/"' >> ~/.bashrc
To test the Ethereum wallet run the command below, which should print the version number:
ethereumwallet --version
[2017-12-18 10:21:31.171] [INFO] main - 0.9.3
ethereumwallet
The Ethereum wallet can be started via the terminal using the command ethereumwallet
:
ethereumwallet
ethereumwallet CLI
ethereumwallet --help
Usage: /opt/ethereum-wallet-mist/ethereumwallet --help [Mist options] [Node
options]
Mist options:
--mode, -m App UI mode: wallet, mist.[string] [default: "wallet"]
--node Node to use: geth, eth [string] [default: null]
--network Network to connect to: main, test
[string] [default: null]
--rpc Path to node IPC socket file OR HTTP RPC hostport (if
IPC socket file then --node-ipcpath will be set with
this value). [string]
--swarmurl URL serving the Swarm HTTP API. If null, Mist will
open a local node.
[string] [default: "http://localhost:8500"]
--gethpath Path to Geth executable to use instead of default.
[string]
--ethpath Path to Eth executable to use instead of default.
[string]
--ignore-gpu-blacklist Ignores GPU blacklist (needed for some Linux
installations). [boolean]
--reset-tabs Reset Mist tabs to their default settings. [boolean]
--logfile Logs will be written to this file in addition to the
console. [string]
--loglevel Minimum logging threshold: info, debug, error, trace
(shows all logs, including possible passwords over
IPC!). [string] [default: "info"]
--syncmode Geth synchronization mode: [fast|light|full] [string]
--version, -v Display Mist version. [boolean]
--skiptimesynccheck Disable checks for the presence of automatic time sync
on your OS. [boolean]
Node options:
- To pass options to the underlying node (e.g. Geth) use the --node- prefix,
e.g. --node-datadir
Options:
-h, --help Show help [boolean]