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.
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.
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:
- Network Name
- Conesus Algorithm. Currently puppeth only supports 2 consensus algorithms i.e Ethash(PoW) and Clique(PoA).
- Sealer Account — you can mention one or more than one account as sealers.
- Pre-fund Accounts — you can prefund your accounts.
- 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.
- 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.
- Botsfolio vs Napbots vs Mudrex | Gate.io Exchange Review
- CoinFLEX Review | AEX Exchange Review | UPbit Review
- AscendEx Margin Trading | Bitfinex Staking | bitFlyer Review
- Bitget Review | Gemini vs BlockFi | OKEx Futures Trading
- AscendEx Staking | Bot Ocean Review | Best Bitcoin Wallets
- Huobi Review | OKEx Margin Trading | Futures Trading
- Grid Trading Bots | Cryptohopper Review | Bexplus Review
- 7 Best Zero Fee Crypto Exchange Platforms
- Anny Trade Review | Huobi Margin Trading
- Decentralized Exchanges | Bitbns FIP | Pionex Review
- 10 Best Places to Buy Crypto with Credit Card