Getting Started Guide
How to Install and Use Geth
This guide covers installing Geth (Go Ethereum), syncing the Ethereum blockchain, and querying accounts, transactions, and smart contracts.
Prerequisites
- -100GB+ disk space (snap sync)
- -Linux or macOS
- -Stable internet connection
Install Geth
Install Geth from package manager or download the binary.
macOS
brew install ethereumUbuntu PPA
sudo add-apt-repository -y ppa:ethereum/ethereum && sudo apt update && sudo apt install gethVerify
geth versionStart Syncing
Start Geth in snap sync mode (fastest way to get a usable node).
Start with snap sync
geth --syncmode snap --http --http.api eth,net,web3Check sync progress
geth attach --exec 'eth.syncing'Note: Snap sync downloads block headers and state data in parallel. It's much faster than full sync. The --http flags enable the JSON-RPC API for querying.
Query the Blockchain
Use the Geth JavaScript console to query accounts, balances, and transactions.
Attach to running node
geth attachCheck balance (in Wei)
eth.getBalance('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045')Get transaction details
eth.getTransaction('0xTXHASH')Get latest block
eth.getBlock('latest')Note: Balances are returned in Wei (1 ETH = 10^18 Wei). Use web3.fromWei(balance, 'ether') to convert.
JSON-RPC API
Query Geth programmatically via the HTTP JSON-RPC API.
Get balance via curl
curl -X POST http://localhost:8545 -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045","latest"],"id":1}'Get block number
curl -X POST http://localhost:8545 -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'Note: The JSON-RPC API is how most tools (Ethers.js, Web3.py, Cast) communicate with Geth. Running your own node means you're not dependent on Infura or Alchemy rate limits.