Skip to content

Geth

Installation

To install geth,

sh
brew update
brew upgrade
brew tap ethereum/ethereum
brew install ethereum

Now, you have installed (evm, geth, abigen, clef, bootnode etc.) tools with it.

sh
which abigen
which evm
which bootnode
which geth
which clef

How to run a in dev mode

Create a new account using geth,

sh
geth --datadir ./data-dev account new

Start geth in dev mode,

First store your password in a secret.txt file. It's the same password which you used when creating a new account using geth.

sh
geth --datadir ./data-dev --dev --password secret.txt

Now, a local blockchain started in your computer in dev mode.

You can find the pipe in the logs to interact with it with a .ipc extension.

It should be in your datadir. In this example, it is is ./data-dev/geth.ipc

Attach geth in another terminal window to interact with the blockchain.

sh
geth attach <ipc-file-path>

To list all functions that you can use,

js
eth

It will print all the functions available to interact with it.

Few examples to interact with it,

js
eth.accounts
eth.chainId()
eth.getBalance(eth.accounts[0])
eth.sendTransaction({from: eth.account[0], to: eth.account[1], value: web3.toWei(1.0)})

If you don't have multiple accounts, you can create them using

sh
geth --datadir ./data-dev account new

To stop it, just do ctrl-c


Running geth on Sepolia Testchain

Let's use another data dir for this one.

To run geth on sepolia testchain,

sh
geth --datadir ./data-sepolia --sepolia --http  -http.api eth,net,web3,admin