Geth - cogeorg/teaching GitHub Wiki
Geth (or Go-ETHereum) is the command line interface that allow you to run and operate a full Ethereum node. Geth is implemented in Go and allows you to mine blocks, to generate Ether, to deploy and interact with smart contracts, to transfer funds, to inspect block history, to create accounts, ... Geth can be used to connect to a public Ethereum network, mainnet or testnet, or to create your own private network for development purposes. The full wiki is available here. Here, you will find brief installation instructions as well as an into on how to get a node up and running using the command line interface.
Installation
Installation instructions for Ubuntu
To install from PPA
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt-get update
$ sudo apt-get install ethereum
Installation instructions for macOS
The easiest way to install go-ethereum is to use the Homebrew tap. If you don't have Homebrew, install it first. You may need to install XCode from the App Store first. Then run the following commands to add the tap and install geth
:
$ brew update
$ brew tap ethereum/ethereum
$ brew install ethereum
Interfaces
- Javascript Console:
geth
can be launched with an interactive console, that provides a javascript runtime environment exposing a javascript API to interact with your node. The Javascript Console includes theweb3
javascript Ðapp API as well as an additional admin API. - JSON-RPC server: geth can be launched with a json-rpc server that exposes the JSON-RPC API
- Command line options documents command line parameters as well as subcommands.
Basic Use Case Documentation
Useful Command line Options
USAGE:
geth [options] command [command options] [arguments...]
COMMANDS:
init Bootstrap and initialize a new genesis block
import Import a blockchain file
export Export blockchain into file
upgradedb Upgrade chainblock database
removedb Remove blockchain and state databases
dump Dump a specific block from storage
monitor Monitor and visualize node metrics
account Manage accounts
wallet Manage Ethereum presale wallets
console Start an interactive JavaScript environment
attach Start an interactive JavaScript environment (connect to node)
js Execute the specified JavaScript files
makedag Generate ethash DAG (for testing)
version Print version numbers
license Display license information
help, h Shows a list of commands or help for one command
ETHEREUM OPTIONS:
--datadir "/home/user/.ethereum" Data directory for the databases and keystore
--keystore Directory for the keystore (default = inside the datadir)
--networkid value Network identifier (integer, 0=Olympic (disused), 1=Frontier, 2=Morden (disused), 3=Ropsten) (default: 1)
--olympic Olympic network: pre-configured pre-release test network
--testnet Ropsten network: pre-configured test network
--dev Developer mode: pre-configured private network with several debugging flags
--identity value Custom node name
--fast Enable fast syncing through state downloads
--light Enable light client mode
NETWORKING OPTIONS:
--bootnodes value Comma separated enode URLs for P2P discovery bootstrap
--port value Network listening port (default: 30303)
--maxpeers value Maximum number of network peers (network disabled if set to 0) (default: 25)
--maxpendpeers value Maximum number of pending connection attempts (defaults used if set to 0) (default: 0)
--nat value NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")
--nodiscover Disables the peer discovery mechanism (manual peer addition)
MINER OPTIONS:
--mine Enable mining
--minerthreads value Number of CPU threads to use for mining (default: 8)
--autodag Enable automatic DAG pregeneration
--etherbase value Public address for block mining rewards (default = first account created) (default: "0")
--targetgaslimit value Target gas limit sets the artificial target gas floor for the blocks to mine (default: "4712388")
--gasprice value Minimal gas price to accept for mining a transactions (default: "20000000000")
--extradata value Block extra data set by the miner (default = client version)
Make sure to check the different options and commands with geth --help