Krishna Aradhi's Blog

Adventures in the blockchain/cryptocurrency world.

Initialize a web3.js Ethereum development environment on Ubuntu 16.04

Install git if you don't already have it.

$ sudo apt-get install -y git

Install build tools.

$ sudo apt-get install -y build-essential python

Install NodeJS. Refer to this guide for more information.

$ curl -sL | sudo -E bash -
$ sudo apt-get install -y nodejs

Create a new folder and a package.json file inside it with the following contents.

  "dependencies": {
    "web3": "0.19.0" // or the latest web3 version

Install dependencies by running the following command in the folder where package.json resides.

$ npm install

Install Ethereum testrpc, which lets you run a local instance of the Ethereum blockchain for development purposes.

$ npm install -g ethereumjs-testrpc
$ testrpc

Open a new terminal window and run the node console after navigating to the folder in which package.json resides.

$ node

Run the following commands inside the node console.

var Web3 = require("web3")

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))


If web3.eth.accounts matches the accounts in your testrpc, you are good to go.

Krishna Aradhi

Read more posts by this author.

New York, NY, USA

Subscribe to Krishna Aradhi's Blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!