(Portuguese version available here.)

Before start writing decentralised applications (DApps) we need to setup our environment with necessary tools.

One recurrent problem that we faced during Blockchain Academy trainings was the software inconsistency between different versions and operation systems. To streamline the process we've created a virtual machine image preconfigured with everything we need through the course.

In this article I will explain which tools we use and how to install it in Ubuntu and macOS. We also provide the link for download the Ubuntu preconfigured image in the end of the article.

Tools

Editing, compiling & publishing

Although there are a few high-level languages that could be used to program a Smart Contract (SC) in Ethereum, Solidity is by far the most used and recommended for most cases. Before send it to the blockchain, the code needs to be compiled to bytecode, which is the EVM really understands.

We chose Atom as the source editor and linter-solidity for linting and colouring.

For compiling and publishing we use theTruffle framework, which as developed by Consensys and we also recommend for testing.

During the training we also use Remix web IDE, which was developed by Ethereum Foundation and allows a very fast development cycle. The code is automatically compiled and can be published in a simplified test EVM running in your browser. My recommendation would be: stick with Remix until you find it that you need a more complete tool for collaborating, testing, etc.

Development Blockchain

Publishing your contract in the Ethereum main network will be the last thing you will do with it — take that literally. Until you make sure your contract is free of bugs you will be using blockchains running your machine, private networks or a public testing network. For a faster development cycle, I suggest using a local blockchain until you need to collaborate with others.

In our training we use two local blockchains: geth in development mode and Ganache. geth is one of the official clients and you can use it to connect to in any Ethereum network. In the development mode, among other things, it comes with an unlocked account loaded with ETH and runs a modified version of Proof-of-Work to generate blocks as soon as a new transaction is received and creates an unlocked account loaded with ETH.

Ganache is a simplified development blockchain. Although you can't do everything with it, I find it very practical for contract publishing and testing. It comes in two flavours: UI and CLI (former TestRPC).

DApp Browsers

The browsers (Firefox, Chrome, Safari, …) we normally use to navigate the "traditional" web are not ready yet for what we call Web 3.0. In this emerging decentralised web, browsers should be able to connect to blockchain networks and understand new protocols, like IPFS, for example.

So, for now, we have two ways to interact with a DApp: use browser extensions/addons or use a DApp Browser.

MetaMask is a extension that manages your wallet and allows you to sign transactions in any Ethereum network — public or private. After installed and configured, it will ask your confirmation for transferring ETH/tokens or interacting with contracts directly from your browser. It currently supports Chrome, Firefox, Opera and Brave.

The Ethereum Foundation maintain a DApp Browser called Mist with two different releases: the full version and a simplified called Ethereum Wallet. The difference is that, while the full version — like any "normal" browser, allows you to use the address bar to navigate in any site you want, Ethereum Wallet runs just one application, the Ethereum Wallet Ðapp (available at wallet.ethereum.org).

Warning: is not recommended to use Mist to navigate in websites you do not trust as it could be exploited to steal your funds.

Javascript libraries

Lastly, to send transactions to an Ethereum network, your application will need to connect to a node. Most common way to establish this connection is using the web3.js library which now supports both JSON RPC and WebSockets protocols.

We should declare web3.js dependency in our project instead of installing it globally, so I'll skip this step and talk about in a future article.

Como a web3.js deve ser declarada como uma dependência do seu projeto ao invés de ser instalada globalmente no sistema, deixarei a explicação para o próximo artigo, onde faremos uma DApp Ethereum com React.

Configuring Ubuntu 16.04.4

The version we've chosen was the 16.04.4 64 bits, available in BitTorrent here.

Node e Git

Some of the tools we'll be installing requires that we setup first Node.JS and Git, so lets start there.

I recommend installing Node through NVM, which allows us to have many different versions on the same machine:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

Close and reopen the terminal and install Node:

nvm install 8.11.1

You could check if it worked with this command:

node --version

To install Git we'll use Ubuntu's package manager:

sudo apt install git

You use this command to force installation if needed:

sudo apt-get -f install

Atom

To download and install most recent version of Atom, hit:



sudo dpkg -i atom-amd64.deb wget -O atom-amd64.deb https://atom.io/download/deb sudo dpkg -i atom-amd64.deb

Atom comes with a package manager (APM) which we'll be using to install linder-solidity:

apm install linter

apm install linter-solidity

Truffle

To install Truffle we'll use Node's package manager (NPM) which comes with it:

npm install -g truffle

Geth

Firstly, download and unpack geth:



wget

tar -xzf geth-alltools-linux-amd64-1.8.3-329ac18e.tar.gz cd ~/Downloadswget https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.8.3-329ac18e.tar.gz tar -xzf geth-alltools-linux-amd64-1.8.3-329ac18e.tar.gz

Move the binaries to a local binary folder:

mkdir ~/.local/bin

mv geth-alltools-linux-amd64-1.8.3-329ac18e ~/.local/bin/geth

And add the chosen folder to system's PATH so you can execute them from any directory:

echo 'PATH="$HOME/.local/bin/geth:$PATH"' >> ~/.profile

Restart your terminal to reload the profile. If you're doing it on a VM you'll probably also need to restart it.

To confirm that geth was correctly installed, try:

geth version

You should see some information about the current installation.

Ganache

The UI version could be downloaded in AppImage format, which doesn't require installation. Download and configure with:

wget https://github.com/trufflesuite/ganache/releases/download/v1.1.0/ganache-1.1.0-x86_64.AppImage

chmod a+x ganache-1.1.0-x86_64.AppImage

mv ganache-1.1.0-x86_64.AppImage ~/.local/bin/ganache.AppImage

And to run, type:

ganache.AppImage

Ethereum Wallet

If you don't have any tool for decompressing ZIP files, install unzip first:

sudo apt-get install unzip

To download and configure Ethereum Wallet, enter:

wget https://github.com/ethereum/mist/releases/download/v0.10.0/Ethereum-Wallet-linux64-0-10-0.zip

unzip Ethereum-Wallet-linux64-0-10-0.zip -d ~/.local/bin/ethereumwallet

echo 'PATH="$HOME/.local/bin/ethereumwallet:$PATH"' >> ~/.profile

Restart your terminal and enter:

ethereumwallet

Configuração no macOS

Homebrew e Node

Homebrew is "the" missing package manager for macOS and we'll be using here. We will also use Node.JS for installing some of required tools.

Firstly, install Homebrew and add Cask:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew tap caskroom/cask

Then install Node. I recommend using NVM, which allows us to have many different versions on the same machine:

touch ~/.bash_profile

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

Close and reopen the terminal and install Node:

nvm install 8.11.1

You could check if it worked with this command:

node --version

Truffle

To install Truffle we’ll use Node’s package manager (NPM) which comes with it:

npm install -g truffle

We'll use Homebrew to install all other tools.

Atom

brew cask install atom

Geth

brew tap ethereum/ethereum

brew install ethereum

Ganache

brew cask install ganache

Ethereum Wallet