Coinmonks
Published in

Coinmonks

Setup Geth Ethereum Private Blockchain and connect to Remix

This tutorial will setup the Geth private ethereum blockchain on ubuntu machine and connect the network to Remix. This tutorial is setting up only 1-node private ethereum blockchain. You can create multi-node private blockchain with a boot node(not included in the tutorial).

What is Geth?

Geth is one of the most popular standalone CLI client for running a node on the ethereum network. Using Geth you can join the ethereum network, transfer ether between accounts or even mine ethers.

Geth Ethereum Private Network Setup:

First of all, we need to install the geth package.

Log into the ubuntu machine and follow the below instructions to install the ethereum geth package.

Commands:

sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install Ethereum

Check the version of geth.

Create a directory, lets name it ‘node’. It will contain all your files and data directories.

Now the geth is installed, lets create accounts for the Ethereum blockchain network. I am creating two accounts. Similarly you can create as many as you want.

Command to create accounts in geth : geth — datadir <directory> account new

It will prompt you for password, then it will create the accounts with the public address and other details. Keep the public address aside.

account creation
public address for the accounts

Now that we have the accounts, lets create a genesis file. Genesis file contains the details of the genesis block, defines initial state of your blockchain. It can be seen as height 0 of your blockchain.

If you already have a genesis file, you can import that or you can create a new genesis file using puppeth, an Ethereum Private Network Manager.

Here when you run ‘puppeth’, it will launch a CLI wizard. To create a genesis block, you will need below details:

  1. Network Name
  2. Conesus Algorithm. Currently puppeth only supports 2 consensus algorithms i.e Ethash(PoW) and Clique(PoA).
  3. Sealer Account — you can mention one or more than one account as sealers.
  4. Pre-fund Accounts — you can prefund your accounts.
  5. Network Id

Here we have created genesis file for PoW(proof of work-Clique) consensus algorithm. Once you export the genesis configuration, it will create the files in the ‘node’ directory.

‘blockchain.json’ is the genesis file that we will be using to setup the private geth blockchain network.

Our genesis file is ready, lets initialise the genesis file.

Command : geth — datadir node/ init node/blockchain.json

This command will throw error if there is any issue with the genesis file.

Create a password file for the accounts created above; so that we don’t need to explicitly unlock the accounts while doing transactions.

Last step, let’s start the geth blockchain using the below command:

Command: geth — networkid 1234 — datadir node/ — port 30303 — ipcdisable — syncmode full — http — http.addr 0.0.0.0 — http.api admin,eth,miner,net,txpool,personal,web3 — allow-insecure-unlock — http.corsdomain “*” — http.vhosts “*” — http.port 8545 — unlock 0xd6b336300929C00d38c5874aa821C134F4d8a255,0x1aDC2f0BD5CcA05FFEBe4704aeA103dB0D6590F7 — mine console — password node/password.txt

Now that the geth private ethereum blockchain network is working, you can see details on the console:

eth.accounts → this will show you the lists of accounts(2) available.

admin.nodeInfo → this will show you the details of the node.

Please refer the geth official site for detailed terminal commands for transactions and other functions: https://geth.ethereum.org/docs/getting-started

Connect the Geth Private Blockchain to REMIX

Next step is to connect the geth ethereum private blockchain to remix.

What is Remix? => Remix is a web-based ethereum IDE. It allows developing, deploying and administering smart contracts for Ethereum like blockchains.

  1. Open REMIX in http mode.

2. In the ‘Deployand Run Transactions’ section, for the Environment select ‘Web3 Provider’. Enter the IP of the private blockchain network.: http://localhost:8545

3. After setting up the environment, you should be able to see the accounts for the particular connection.

Yippee!!!! You have successfully created your Ethereum Private Network using Geth.

Happy Learning!!

Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing

Also, Read

--

--

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