How Do I set up my own Ethereum Testnet?

A step by step walkthrough of how to set up and run your own Ethereum testnet using Geth & Homebrew

CoinBundle Team
CoinBundle
6 min readNov 6, 2018

--

Ethereum software enables a user to set up a “private” or “testnet” Ethereum chain which is separate from the main Ethereum chain. This is useful for testing distributed apps built on Ethereum without having to expose your apps or trials to the real Ethereum network using real Ether. You either pre-generate or mine your own Ether on your private Ethereum chain, so it is a much more cost effective way of trying out Ethereum… which is what brings us here: learning how to make your very own Ethereum testnet, which can most definitely be difficult without the proper guidance. Lucky for you, you’ve come to the best place for learning more about how cryptocurrency & blockchain works. So, without further adieu, let’s go over how to set up your very own Ethereum testnet.

This is not intended as financial investment advice.
This article will explain how to set up and use your own Ethereum testnet.

Target audience:

The following information is intended for somewhat experienced cryptocurrency users who are looking to set up their own private blockchain in Ethereum using Geth.

What will be needed to get started:

  • Computer, laptop, or device with necessary internet access
  • Ether
  • Homebrew
  • Geth
  • General coding and software development interest

Expectations:

If you follow these instructions, then you can expect to successfully set up your own little Private Test Net, test out ETH, issue yourself Ether, setup nodes, and send out transactions on this Privnet using Geth.

Step-by-step Walkthrough

Step 1: Install Homebrew & Geth

Step 2: Create Your Genesis File

Step 3: Start Your Node

Step 4: Mine Ether

Wrapping it all up

Step 1: Install Homebrew & Geth

The first thing you’ll need to do is download Geth. The best way to do this is to open Terminal and install homebrew.

Source

Once you’ve done this, go ahead and install geth.

Source

Step 2: Create Your Genesis File

The Genesis Block is known as the first block in the chain. This is the only block on the network that doesn’t point to the predecessor block. By default the Genesis Block is hard coded into Ethereum clients. However, as we are setting up our own test network, this step is essential since all subsequent blocks will be referencing this Genesis Block. So, in order to properly initialize and set up that block, you must create a Genesis File which defines the characteristics of that block and each following one on that blockchain.

The first thing that needs to be done in order to properly set up your genesis file is to create a directory that will hold your network files. Try using this code:

Source

Next, you want to actually create your Genesis file. This can simply be done in one line of code:

Source

Now that you have the actual Genesis File set up, open it and define its characteristics. Each parameter has to do with variable factors for the genesis file that you just made, so it’s important that you don’t overlook this crucial step. Try using this sample code:

Source

Step 3: Start Your Node

Now that you’ve created and defined your Genesis File, you’re ready to start running your node! The first thing you need to do is Initialize the geth terminal with your genesis blockchain file: myGenesis.json

Source

The json file to be used for configuring the Ethereum node. Now you should be ready to start running your Ethereum peer node, which requires that you set up a way for peers to join your network. Here’s some sample code which should get you started:

Source

When using networkid, any number can be used when writing your code — in this case, the number “1114” is used. Just remember that other peers joining your network must use the same one. Your output should look like this:

Source

FInally, you’ll have to create an account. This can also quickly be done in just one line similar to this sample:

Source

Don’t forget the passphrase that you set up when creating your account.

Step 4: Mine Ether

Any operation on Ethereum is possible only if you have Ether (the currency used on the Ethereum blockchain). When you setup a test network, you will need to mine some money into the accounts, otherwise you won’t be able to perform any operations.

First, however, you’ll need to set up your default account. This can also be done quickly in one line:

Source

Mining is done by the command miner.start(). Be aware that this command will take some time to execute and accumulate Ether into the previously created account. To stop mining, run the command miner.stop().

I did everything — now what?

And there you have it! You’ve (hopefully) just successfully set up your own private Ethereum testnet. Using this, you’ll be able to accumulate much more coding knowledge and even gain experience on the technical side of things. Creating your own Ethereum blockchain is significantly more useful, educational, and safer than the public testnet. Moving forward, you can decide on whether or not you’d like to add more peer nodes to your network. Otherwise, you should be good to go and your testnet should be up and running just fine.

Other CoinBundle Crypto Blog articles that will help you along:

Or, if you would like to look over everything on our blog to stay fresh and up-to-speed, here is the link: CoinBundle Crypto Blog

Conclusion

So why does this all even matter to begin with? Well, creating your very own Ethereum testnet is actually a great way to accumulate some tangible experience for a rather technical concept. Having the ability to understand how cryptocurrency works from a blockchain perspective is crucial to expanding your own knowledge of how the system functions as a whole. Not to mention, you’ll be much more informed and articulate when conversing with others who do have the technical background and experience to understand blockchain from this side of the operation. Irrespective of how much technical or coding experience you have, take the time to go through this process and gain that valuable technical exposure needed to understand how blockchain ties into cryptocurrency.

Happy investing!

What are some other cool ways of setting up your own Ethereum Testnet?
Let us know in the comments!

--

--

CoinBundle Team
CoinBundle

CoinBundle is the easiest way for people to invest in cryptocurrencies. Backed by top Silicon Valley VCs and Y-Combinator. Learn more: coinbundle.com