LinuxCommandLibrary

geth

Run an Ethereum node

TLDR

Connect to the main Ethereum network and automatically download the full node

$ geth
copy

Connect to the Ropsten test network
$ geth --testnet
copy

Create a new account
$ geth account new
copy

Enable mining
$ geth --mine
copy

SYNOPSIS

geth [OPTIONS]
geth [ARGS...]
geth attach [URL]
geth console [OPTIONS]
geth init <GENESIS_FILE>
geth removedb

PARAMETERS

--datadir <path>
    Path to the root data directory for the node.

--networkid <id>
    Explicitly set the network ID (e.g., 1 for mainnet, 3 for Ropsten).

--syncmode <mode>
    Blockchain synchronization mode: full, fast, snap, or light.

--mine
    Enable CPU mining.

--etherbase <address>
    Public address for block rewards (coinbase).

--rpc
    Enable the HTTP RPC server for client applications.

--rpcaddr <ip>
    HTTP RPC server listening interface (default: localhost).

--rpcport <port>
    HTTP RPC server listening port (default: 8545).

--rpccorsdomain <domains>
    Comma-separated list of domains to accept cross-origin requests from.

--ws
    Enable the WS-RPC server (WebSocket).

--wsaddr <ip>
    WS-RPC server listening interface (default: localhost).

--wsport <port>
    WS-RPC server listening port (default: 8546).

--ipcdisable
    Disable the IPC (Inter-Process Communication) interface.

--ipcpath <path>
    Filename for IPC socket/pipe.

--maxpeers <n>
    Maximum number of network peers (default: 50).

--verbosity <level>
    Logging verbosity (0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=trace).

--console
    Start the interactive JavaScript console.

--attach <url>
    Attach to a running geth node via RPC/IPC URL.

--unlock <addresses>
    Comma-separated list of accounts to unlock during startup.

--password <file>
    File containing password(s) for unlocked accounts.

--allow-insecure-unlock
    Allow insecure account unlocking via HTTP RPC (use with caution).

--dev
    Enable developer mode with a pre-configured private network.

--txpool.globalslots <n>
    Maximum number of executable transaction slots for the global transaction pool.

DESCRIPTION

geth is the official command-line interface for running an Ethereum node implemented in Go. It allows users to connect to the Ethereum network (mainnet, testnets), synchronize the blockchain, manage accounts, send transactions, deploy smart contracts, and interact with the Ethereum Virtual Machine (EVM). It serves as a full node, light node, or even a remote client to an existing node. geth is essential for developers building on Ethereum, miners, and users wanting to have a direct interface with the decentralized network. It provides a JavaScript console for interactive operations and exposes various RPC interfaces (HTTP, WebSockets, IPC) for programmatic access, making it a cornerstone of the Ethereum ecosystem.

CAVEATS

Running a geth full node can be resource-intensive, requiring significant disk space (hundreds of GBs) and RAM. Unlocking accounts via command-line flags or insecure RPC interfaces poses security risks and should be avoided in production environments. Synchronization can take a long time, especially for a full sync from scratch. Command options and default behaviors may evolve with future protocol upgrades.

RPC AND IPC INTERFACES

geth exposes powerful RPC (Remote Procedure Call) interfaces over HTTP, WebSockets (WS), and IPC (Inter-Process Communication). These interfaces allow developers and applications to interact programmatically with the Ethereum blockchain, query node status, manage accounts, send transactions, and deploy smart contracts. IPC is generally preferred for local applications due to its higher security and performance, while HTTP/WS are used for remote or web-based interactions.

SYNCHRONIZATION MODES

geth offers several blockchain synchronization modes:
Full Sync: Downloads and validates all blocks from genesis, including executing all transactions. Requires significant disk space and time.
Fast Sync: Downloads block headers and receipts, then state trie data, skipping transaction execution for older blocks. Faster and less demanding than full sync.
Snap Sync: The default and most efficient sync mode, it downloads recent state snapshots directly from peers, significantly reducing sync time and disk usage.
Light Sync: Downloads only block headers and relies on peer nodes to serve state information on demand, requiring minimal local storage but relying heavily on network connectivity.

ACCOUNT MANAGEMENT

geth provides robust tools for managing Ethereum accounts. Users can create new accounts, import existing ones, and manage their private keys securely, typically encrypted with a passphrase within the geth datadir. Accounts are used for signing transactions, participating in mining, and interacting with smart contracts. While accounts can be unlocked for automation, careful security practices are crucial to protect private keys.

HISTORY

geth (Go Ethereum) is the original and most widely used client implementation of the Ethereum protocol, developed by the Ethereum Foundation. It was launched alongside the Ethereum network in 2015. Over the years, geth has continuously evolved, incorporating major protocol upgrades (hard forks) like Homestead, Metropolis, Constantinople, Istanbul, Berlin, London, and Shanghai. Key developments include various synchronization modes (fast, light, snap) to improve user accessibility and reduce resource demands, as well as robust RPC interfaces crucial for dApp development and ecosystem tooling.

SEE ALSO

solc(1), clef(1), abigen(1), bootnode(1)

Copied to clipboard