Aug 2, 2018

2 min read

How to install and execute Truffle on an Ubuntu 16.04

Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier.
See details on truffle website: http://truffle.readthedocs.io/en/latest/

This was made on an Ubuntu 16.04


Install packages

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install curl git vim build-essential

Install NodeJs

sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get install nodejs

Install Truffle

sudo npm install -g truffle

Install testrpc

#  sudo npm install -g  ganache-cli
# ganache-cli

Create a project

Init Truffle project

# mkdir myproject
# cd myprojet/
# truffle init
# truffle compile

Deploy contracts

# truffle migrate

It should launch transaction on testrpc process output

Listening on localhost:8545
Transaction: 0xc1cbc63cd0644604bc41ebbd9bd9998ce14f5ae2b27cb2e2d3fc5ce823574e62
Contract created: 0xbbdef31b721512c7c9bc05a00e8c24fa4e15e1f6
Gas usage: 139321
Block Number: 0x01

And run migration
Running migration: 1_initial_migration.js
Deploying Migrations...
Migrations: 0xbbdef31b721512c7c9bc05a00e8c24fa4e15e1f6

Create DAPP

# truffle build

Launch server for DAPP testing

# truffle serve

Output should display

Serving app on port 8080...
Completed without errors

Optional: add -p option to change port

Go to http://localhost:8080 to see the Dapp
You can send Metacoin to an address (ex: 0x2742c08e81208d01ff48a8c0f7d7c738625f92f5 as see above from testrpc)
Each transactions are displayed on the testrpc process output

Love podcasts or audiobooks? Learn on the go with our new app.