If you want to create smart contracts and dApps using Ethereum, you first must have a working environment. Here I’ll share with you my personal setup and why I choose to use it.
The big picture
Our working environment should contain three main components:
Keep it as light as possible
1. Google Chrome (or Chromium for Linux users)
2. MetaMask and/or Ethereum node of your choice
3. Optional – SSH client and terminal
Digital Ocean Droplet
This is your real working environment. Where your code will run
· Ubuntu 16.04 x64
· 1 CPU
· 1 GB RAM
· 1 GB SWAP
· Optional – Chai
· Optional – Meteor
C9 IDE/ SSH Terminal
Register to C9 IDE. We’ll only use it as a browser based terminal with SSH capacities.
This is how our working environment looks like:
Creating the Digital Ocean Droplet:
- Create your digital ocean account. Use the following link to get 10 USD voucher. Pay attention; the subscription is auto renewing. If by the end of the first month you don’t want to be charged again, you should manually change your billing settings.
- Once logged in press
Create -> Droplets. Choose the one that has:
1 CPU 64 bits
1 GB RAM
Ubuntu 16.04 X64
- Name your droplet and press the
- After few minutes you should get an email with your Droplet IP address and root password.
Connecting to your Droplet using the c9.io terminal and SSH (Optional – can also be achieved using a locally installed SSH client and terminal):
- Create a free account at c9.io
- SSH into your droplet by typing
- When you first log into your droplet, you’ll be asked to change your root
Set your Digital Ocean Droplet:
|Create SWAP file 1 GB of RAM isn’t enough.||
sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
|Add SUDO user Don’t always work as root!||
adduser shlomi sudo
|Change your user account||
su shlomi cd /home/sholmi
|Install NodeJS and NPM This is the framework on which we’ll develop our app.||
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs sudo apt-get install -y build-essential sudo apt-get install npm
|Install Truffle and TestRPC||
npm install -g truffle npm install -g testrpc
The relation between Truffle and testRPC:
testRPC creates a mock Ethereum blockchain. It saves you a lot of time when testing your smart contract. Because you’re the owner of the blockchain, you can mine new blocks instantly. Usually, when using Ethereum, you’ll have to wait for new blocks to be mined whenever you check you smart contract and while block time is much faster in Ethereum than it’s in Bitcoin, it might still be very distracting to have a test case that contains more than 2-5 interaction with the blockchain.
Another great benefit of using testRPC is the fact that it immediately creates multiple accounts with balances so that you can test the use of your smart contract by multiple users.
When you first deploy testrpc you’ll be giving a mnemonic 12 words phrase. If you write this phrase down, you can later re-deploy your restRPC with the same accounts.
Working with truffle:
|Create a working folder and initialize your truffle project|
mkdir myProject cd myProject truffle init
|Make sure testRPC runs in the background|
testrc -m "tortoise fall alarm push dream proof broccoli size draft betray view gather"
|Test your project|
truffle migrate truffle test
Tip for metamask and testRPC:We can set metaMask to work with our own private testRPC node simply by adding it into our custom rpc list. Open metaMask and change to
custom RPC. Then add
http://yourDropletIPAddress:8545 //You might need to open port 8545And voila, Now metaMask is set to work with your own private blockchain!