geth
Run an Ethereum node
TLDR
Connect to the main Ethereum network and automatically download the full node
Connect to the Ropsten test network
Create a new account
Enable mining
SYNOPSIS
geth [options] command [command options]
PARAMETERS
--datadir value
Data directory for the databases and keystore.
--networkid value
Network identifier (integer, 1=mainnet, 5=goerli, etc).
--http
Enable the HTTP-RPC server.
--http.addr value
HTTP-RPC server listening interface (default: localhost).
--http.port value
HTTP-RPC server listening port (default: 8545).
--http.api value
API's offered over the HTTP-RPC interface (default: eth,net,web3).
--ws
Enable the WS-RPC server.
--ws.addr value
WS-RPC server listening interface (default: localhost).
--ws.port value
WS-RPC server listening port (default: 8546).
--ws.api value
API's offered over the WS-RPC interface (default: eth,net,web3).
--syncmode value
Blockchain sync mode ('fast', 'full', 'light').
--gcmode value
Garbage collection mode ('full', 'archive').
--miner.threads value
Number of CPU threads to use for mining.
account
Subcommands to manage accounts (new, update, list, import, export).
attach
Attach to a running geth instance.
--help
Show help message.
DESCRIPTION
Geth (Go Ethereum) is the command-line interface for running a full Ethereum node implemented in Go. It allows users to interact with the Ethereum blockchain, mine Ether, deploy smart contracts, send and receive transactions, and explore block data. Geth supports various networking protocols for connecting to the Ethereum network, including the mainnet, testnets (like Goerli or Sepolia), and private networks. It provides extensive control over node configuration, allowing fine-tuning of resource usage, data storage, and network connectivity. Geth is a critical tool for developers building decentralized applications (dApps) and for users participating in the Ethereum ecosystem.
Key features include:
- Block synchronization.
- Transaction management.
- Smart contract deployment and interaction.
- Mining capabilities.
- Account management.
- Detailed logging and monitoring.
CAVEATS
Running Geth can consume significant system resources, especially disk space. Choosing the appropriate sync mode and garbage collection mode is crucial for optimal performance. Security is paramount when exposing RPC interfaces; restrict access as much as possible. Mining requires a valid Ethereum account and sufficient computational power. It is also worth keeping the node updated to the latest version for security patches and bug fixes.
RPC API
Geth exposes a rich set of JSON-RPC APIs that can be used to interact with the Ethereum node. These APIs allow developers to query blockchain data, submit transactions, deploy contracts, and much more. The available APIs are dependent on the enabled modules. Common API groups include 'eth', 'net', 'web3', 'personal', and 'admin'.
NETWORKING
Geth uses a peer-to-peer networking protocol to connect to other Ethereum nodes. It discovers peers through a distributed hash table (DHT) and maintains connections with a subset of peers to synchronize blockchain data. The `--maxpeers` option controls the maximum number of connected peers.
HISTORY
Geth was one of the earliest Ethereum implementations and has been under active development since the beginning of the Ethereum project. It is written in Go and is one of the most popular Ethereum clients. Originally created by the Ethereum Foundation and continues to be actively maintained by the Ethereum community. Over time, it has evolved to support new Ethereum features and improvements, such as the transition to Proof-of-Stake (The Merge). It's usage is vital for any Ethereum developer.
SEE ALSO
eth(1), abigen(1), bootnode(1)