Sunday, February 15, 2015

How to Set up a Test Network for Ethereum

Please use the instructions at this page instead -- I was never able to get a return value from a contract using the setup described below.



Why set up the Testnet

The purpose of this setup is so you can develop smart contracts -- not for developing Ethereum itself.

Set up the VM

Create a VirtualBox Virtual Machine and install Ubuntu 14.04.1 inside of it -- name this VM "EthDev".
The VM should have 4096 MB of Base Memory.
Launch the EthDev VM and run these commands:

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum

At this point you should make sure Ubuntu is set up exactly the way you like it, because we are going to clone the VM and you don't want to have to set that stuff up twice. (I like to make sure that VirtualBox Guest Additions are installed and that various command line settings that I prefer have also been set up.)

Now that your VM is set up, exit the VM.
Go to the VirtualBox Manager and open the Settings window.
Tick "Enable Network Adapter" for only one Adapter and be sure it is "Attached to" "Bridged Adapter".

Clone VM

Clone the VM and name it "EthTestNet" and tick "Reinitialize the MAC address of all network cards".
Launch the EthTestNet VM and run this command:

sudo gedit /etc/hostname
sudo gedit /etc/hosts

In the editor, change the name of the machine to "EthTestNet" and save the file.
Exit the VM.
 Go to the VirtualBox Manager and change the EthTestNet VM's Base Memory to 3072 MB.
Re-launch the EthTestNet VM.

Launch EthTestNet

Figure out what your IP address is by typing:


Make a note of the EthTestNet IP address.
(In my case it is:
From the command line run:

which eth
Make a note of the path to the eth program.
(In my case it is located at: /usr/bin)
From the command line run the following, but replace the highlighted text with the IP and path for your machine:

cd /usr/bin && ./eth -u -l 30300 -d /tmp --upnp off

Minimize the EthTestNet VM so it keeps running in the background.

Launch EthDev

EthDev is where you will run the GUI client program, AlethZero.
This is where you can do all your development of smart contracts.

From the command line run:


When the GUI client appears, choose menu: Network > Use UPnP (un-check)
Then: Network > Connect to Peer...
Then enter this peer (but substitute the highligted text with your own IP):
Note that the port is "30300" (which is different from the default "30303").

Now click the "Go!" button.
You should see, at the bottom of the window, the text that used to say "0 peer(s)" now shows you connected to peers.

Mine (fake) Ether

Select menu item: Debug > Force Mining (should have a check next to it).
Then click the "Mine" button.
You should see, at the bottom of the window, the text that used to say "0 wei" now shows you mining fake Ether (the smallest unit is wei).

Develop Smart Contracts

Now you're ready to develop smart contracts.

No comments:

Post a Comment