Back to homepage

Introducion to GoEthereum (Geth): installation and first steps

Published

In a nutshell, Blockchain nodes keep a copy of the blockchain and offer an API that applications and users can use to query data from the blockchain or submit transactions.

Nodes can run different clients but the most common one is GoEthereum, or Geth.

Let's review how to install it and run some API queries.

Install GoEthereum

GoEthereum is wrtiten in the Go programming language so that's actually required. To check if it's already isntalled in your system, run go version in your terminal.

If the go command is not found, you can download and install it from here.

To install Geth, we'll also need Homebrew, which you can also install by running the command indicated in its homepage.

With Go and Homebrew installed, run the following commands to add the ethereum source to homebrew and install it.

brew tap ethereum/ethereum
brew install ethereum

Once done, you can run geth help to get a list of available commands.

If you want to install it in Windows or other systems, follow this installation guide

Other node clients

As mentioned earlier, there are other clients like MEV-Geth, focused on mitigating miner-extractable value (or MEV) risks, or Erigon focused on efficiency. Feel free to check them out 😉

Using GoEthereum to query the node

In order to use Geth, we actually need a blockchain node to connect to. There are multiple node providers, but my go-to is Chainstack which has a free tier (✅), supports a ton of different blockchain protocols (✅), and offers nodes in multiple regions across the globe (✅) 😊

It's also super easy to use. Follow these links to:

Once we have our blockchain node access details, we can connect our local Geth client using geth attach https://your-node-url/1234567890.

Once connected you can see all the available methods by running web3.eth. You can, for example:

  • query the current block number with web3.eth.blockNumber
  • get all the transactions from a specific block with web3.eth.getBlock(14741132)
  • get the details of a specific transaction with web3.eth.getTransaction('0x47a1348f52fb7c38005936eaa90cc7475c3ca486165fcab1b359780e4eb7b62e')
  • check the balance of a wallet with web3.eth.getBalance('0x123123213123312abcdef')

TAGS

If you enjoyed this article consider sharing it on social media or buying me a coffee ✌️

Buy Me A Coffee