Setting up an IDE for Solidity contract development remotely

  • Posted on: 11 November 2017
  • By: Jackson


Photo by Tony Webster on Unsplash

Background

As I spend more time writing Ethereum Smart Contracts, I started looking for IDEs that lets me code, test and deploy productively. This is a documentation of how I set up my Mist wallet and Remix Browser for development. While Mist wallet lets me code on the computer at home, Remix Browser lets me do so from anywhere. My Ethereum node runs on Geth, deployed on Google cloud and syncs 24/7 so both my Mist wallet and Remix Browser connects to this node.

I have previously written on how I sync as a service. This post is in some ways a continuation of that previous post and assumes that you have already gotten your node up and running. Mine connects to Ropsten instead of the main Ethereum blockchain because as always, I am just mucking around.

Mist Wallet

Download your Mist wallet here. Open command line and execute mist with the following command:

mist --rpc http://<your node's IP address>:<your node's port> --swarmurl="http://swarm-gateways.net"

The argument --rcp states that your mist should connect to a remote note instead of running its own. The argument --swarmurl states a separate swarm gateway because I do not run my own. In the absence of a swarm gateway, Mist doesn't start. So just include this. 

This is how mine looks like after it starts.

Remix Browser

My Remix Browser runs on the cloud and was installed by following the installation instructions here. To keep my Remix Browser running continuously in the background, I created a script as follows (you need to install Screen, a terminal multiplexer)

sudo pico browser.sh

And wrote this in the script:

#!/usr/bin/env bash
echo "Remix at work!"
screen -dmS remix npm start

And then I set it to be executable:

sudo chmod +x browser.sh

And then I executed it:

bash browser.sh

To check if it's running like it should, execute screen:

screen -x remix

Remix Browser runs as a localhost and listens via port 8080. I run Apache web server so I did a proxypass to redirect traffic to and fro via a virtual host. To do this, edit 000-default.conf:

cd /etc/apache2/sites-enabled
sudo pico 000-default.conf

Add a new VirtualHost section to redirect traffic from localhost at port 8080 to your virtual host's URL.

<VirtualHost *:80>
    ProxyPreserveHost On
    ServerName your.url.here
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://localhost:8080/
</virtualhost>

Since I access my Remix IDE anywhere I wish, I secured it by creating a new username and password:

sudo htpasswd -c /etc/apache2/.htpasswd myusername

And I secured this virtual host by added this to the configuration:

<VirtualHost *:80>
    ProxyPreserveHost On
    ServerName your.url.here
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://localhost:8080/
    <Proxy *>
        Order deny,allow
        Allow from all
        Authtype Basic
        Authname "Password Required"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
    </Proxy>
</virtualhost>

Now whenever I browser to my Remix IDE address, it ask me for my username and password:

Once through, I could connect to my geth node. To do this, in Remix, select Web3 provider under "Environment" and enter your Geth Node's URL.

What's Next?

With Remix and Mist connected to my remote Geth node, now I can code smart contracts on the beach, in the plane and during a holiday!

Tags: 

Add new comment

Pages