Ethereum: DIY Tools for Smart Contracts

What tools do you need to start working with Ethereum smart contracts?

The Solidity Online Compiler provides a quick way to experiment with smart contracts without installing any software on your machine. Another promising online alternative is Cosmo.

However at some stage you’ll probably want to put together a local Ethereum development environment. Here are some suggestions for how to do that on an Ubuntu machine.

Since I’m just feeling my way into this new domain, I’m not sure to what degree all of these are necessary. I do know for sure, that Truffle and testrpc are crucial.

Preliminaries

Accurate time is important. Probably not critical to have nanosecond or microsecond accuracy. But you want your computer’s clock to be correct to within a few milliseconds.

An owner of a grandfather clock needs to regularly wind it and check its time. That’s fine for an antique heirloom. But you don’t want to have to do the same for your shiny computing machine, do you? Hell no! Nothing sexy about that. Rather ensure that you have NTP running. NTP will take care of timekeeping tasks, adjusting your clock’s time and offsetting any inherent drift.

Command Line Client

The Ethereum command line client allows to have direct access to the blockchain. By running the client you’ll be able to mine blocks, send and receive ETH, deploy and interact with smart contracts.

There are multiple implementations of the client:

The third of these is the most popular and actively developed.

Install from PPA

  1. Add the Ethereum PPA.
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository -y ppa:ethereum/ethereum
$ sudo apt-get update

{:start=“2”} 2. Install Geth.

$ sudo apt-get install -y ethereum

{:start=“3”} 3. Check the version.

$ geth version
Geth
Version: 1.7.3-stable
Git Commit: 4bb3c89d44e372e6a9ab85a8be0c9345265c763a
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9
Operating System: linux
GOPATH=
GOROOT=/usr/lib/go-1.9

New releases come out every few weeks, so it’s not a bad idea to update from time to time.

This is a good time to synchronise with the blockchain.

Install the Docker Image

Alternatively, if you prefer to keep things in containers, there’s also a Docker image.

$ docker run ethereum/client-go:stable version
Geth
Version: 1.7.3-stable
Git Commit: 4bb3c89d44e372e6a9ab85a8be0c9345265c763a
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.9.2
Operating System: linux
GOPATH=
GOROOT=/usr/local/go

Solidity Compiler

There are currently three languages for developing smart contracts:

  • Serpent
  • LLL and
  • Solidity.

Solidity appears to be winning the popularity competition, so we’ll focus on that.

On a Ubuntu machine there are a few options for installing the Solidity compiler. Check out the official install documentation.

Install from PPA

  1. Install from the PPA we added above.
$ sudo apt-get install solc

{:start=“2”} 2. Check the version.

$ solc --version
solc, the solidity compiler commandline interface
Version: 0.4.19+commit.c4cbbb05.Linux.g++

Install the Docker Image

You can also take the Docker route.

$ docker run ethereum/solc:stable --version
Version: 0.4.19+commit.c4cbbb05.Linux.g++

Ganache Testing Client

A testing client simulates interactions with the Ethereum blockchain, making the development process quicker and more flexible.

The Ethereum ecosystem is evolving rapidly. The TestRPC testing client has become Ganache.

Update Node

If your version of Node is an antique then you’ll need to update. First check which version you currently have.

$ node --version
v6.12.2

If that’s less than 6.11.15 then run the following to update.

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Install with NPM

$ sudo npm install -g ganache-cli

Truffle

Truffle is a development environment for Ethereum. It works well with Ganache.

Install with NPM

$ sudo npm install -g truffle@4.0.1

Conclusion

That’s pretty much everything you need to start writing smart contracts.