Ethereum Ropsten Test Net on Azure VM

Ubuntu Server 16.04 LTS

When creating a DAPP on Ethereum we often come to a point where we need to test our DAPP on available Ethereum TestNets.

Few awesome frameworks available for DAPP development such as truffle, has made developer’s life easy. Writing, compiling and deploying smart contracts using Solidity is also supported with truffle.

However as said earlier once the development is completed, we need some test environment to verify the working of our newly created DAPP, here in this post we will see how to connect to Ropsten Test Net using Azure VM (Ubuntu Server 16.04 LTS).

Step 1: Creating Azure VM (Ubuntu Server 16.04 LTS)

Create a virtual machine on your Azure subscription, for details you can refer this link, for this post we will select Ubuntu Server 16.04 LTS

Search for Ubuntu Server 16.04 LTS

Follow the steps under ‘Create virtual machine’ blade, for this example we have selected size of ‘Standard D2s v3 (2 vcpus, 8 GB memory)’, and deploy.

Step 2: SSH into Azure VM

Once the VM is successfully deployed you can navigate to its ‘Overview’ section and copy the SSH command for connecting to VM

Create VM and get SSH address

Open console and connect using above copied SSH command, enter your password, you should be able to successfully connect to your machine

SSH into VM

Step 3: Install supervisor on Azure VM

Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems. To install supervisor, paste below command on ssh console,

$ sudo apt-get install supervisor

Step 4: Install GETH

GETH is official GO implementation of Ethereum protocol. To install GETH, paste below commands in given order on ssh console,

$ sudo apt-get install software-properties-common

$ sudo add-apt-repository -y ppa:ethereum/ethereum

$ sudo apt-get update

$ sudo apt-get install geth

Step 5: Configure supervisor to run GETH

Now we will create a configuration file for supervisor to run GETH, we will use nano editor for this,

$ sudo nano /etc/supervisor/conf.d/geth.conf

Above command will open up editor in ssh console with geth.config, paste below code and save the file (Note: — below are two dashes ‘-’),

[program:geth]

command=/usr/bin/geth — testnet — fast — rpc — rpcaddr 127.0.0.1 — rpcport 6545 — rpccorsdomain * — rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3

autostart=true

autorestart=true

stderr_logfile=/var/log/supervisor/geth.err.log

stdout_logfile=/var/log/supervisor/geth.out.log

Step 6: Restart supervisor to startup GETH

Once the configuration file is correctly added we will now restart supervisor to startup GETH, paste below command on ssh console,

$ sudo supervisorctl reload

This will start up GETH and the node will start syncying to Ropsten Test Net, we will need patience here as GETH will sync Ropsten Test Net, the latest current block as of writing this post is 3191876, check here.

Step 7: Test, Attach a console to our GETH instance

Once the sync is completed, how to check this?

Connect to GETH by attaching a console, paste below command in ssh console,

This will open up GETH console, check the latest block number as follows,

$ > eth.blockNumber

Attaching to GETH console

If the blockNumber and the one in step 6 is same, GETH has completed the sync.

Step 8: Troubleshoot by checking logs and outputs

We can check for logs and outputs in below two files,

$ sudo nano /var/log/supervisor/geth.err.log

$ sudo nano /var/log/supervisor/geth.out.log

Step 9: Deploy smart contracts and DAPP on Ropsten Test Net

Now we have fully synced node which is connected to Ropsten TestNet you can now deploy smart contracts, create accounts, deploy dapps, play with GETH console.

Conclusion

We can easily setup a test node for Ropsten TestNet using Azure VM, we can deploy and test our dapps on Ropsten TestNet before deploying it to Ethereum MAINNET.