Published in


Hands On: Creating Your Own Local Private Geth Node (Beginner Friendly)

Source: https://altcointoday.com/
Source: https://tenor.com/

What will we build?

A local testnet Ethereum blockchain using Geth.

  • Testnet: This will not mine real Ethers. Only fake ones. It is perfect for testing dApps, or for just playing around.


  1. MacOS
  2. Homebrew (Download link: https://brew.sh/)
  3. XCode (Get from AppStore)

Setting Up Development Environment

Step 0: Download Geth using Homebrew

Fire up your terminal and enter the following command. Make sure you already have Homebrew installed, otherwise this command will not work for you.

$ brew tap ethereum/ethereum
$ brew install ethereum

Before going any further, let me clear what Geth is

geth is the the command line interface for running a full ethereum node implemented in Go. You can mine real ether (if you’re on mainnet), transfer funds between addresses, create smart contracts, make transactions, explore the chain, use Web3 etc.

Let’s get crackin’ baby!

Genesis Block, The Special Block

Every blockchain has a genesis block, that is the first block. Height of this block is 1. It does not hold any transactions. All later blocks get appended to this block.

Step 1: Create Genesis block

Make any directory in which you want to store your blockchain data.

$ mkdir -p ethereum-tutorial && cd ethereum-tutorial
$ mkdir -p private && cd private
$ puppeth

Step 2: Initialise the genesis block

It’s time to create chaindata and keystore for local blockchain. chaindatawill store all data related to blockchain and keystore will store private keys associated with accounts on the blockchain.

$ geth --datadir ~/ethereum-tutorial/private init niharikatestnet.json

Step 3: Creating accounts

We need to create accounts on this blockchain to play around with it.

$ geth --datadir . account new
$ geth --datadir . account list

Step 4: Write a Shell Script to Start Blockchain

In any text editor, create a file named startnode.sh in private folder.

geth --networkid 4224 --mine --minerthreads 1 --datadir "~/Desktop/Playground/ethereum-tutorial/private" --nodiscover --rpc --rpcport "8545" --port "30303" --rpccorsdomain "*" --nat "any" --rpcapi eth,web3,personal,net --unlock 0 --password ~/ethereum-tutorial/private/password.sec --ipcpath "~/Library/Ethereum/geth.ipc"
$ chmod +x startnode.sh
$ ./startnode.sh

Step 5: Connect to running geth

Let’s get connected with this geth node. On another tab in terminal, run the command.

$ geth attach
Source: https://tenor.com/

Step 6: Query the blockchain

Let’s see what all accounts are present on this blockchain.

> eth.accounts
> eth.getBalance(eth.accounts[0])
> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")

Info: Stop Mining or Start Mining

If you wish to stop mining process:

$ miner.stop()
$ miner.start()

Step 7: Make transactions

Let’s send some ethers from one account to another.

> eth.sendTransaction({from: eth.coinbase, to: eth.accounts[1], value: web3.toWei(10, "ether")})
> web3.fromWei(eth.getBalance(eth.accounts[1]), "ether")



Elijah McClain, George Floyd, Eric Garner, Breonna Taylor, Ahmaud Arbery, Michael Brown, Oscar Grant, Atatiana Jefferson, Tamir Rice, Bettie Jones, Botham Jean

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store