Hi everyone, I quickly wrote these instructions on how to install [Truffle](http://truffle.readthedocs.io/en/latest/) and [testrpc](https://github.com/ethereumjs/testrpc) on Ubuntu Linux to test smart contracts before deploying them to an Ethereum Virtual Computer. I made it to help me remember for next time, but perhaps someone else will find it useful as well! You can install these development tools directly onto your workstation, but I prefer to use an Ubuntu virtual machine running in [VirtualBox](https://www.virtualbox.org/). This way you can separate your development environment from your general purpose desktop environment. Also, it's safer to test software installations in a virtual machine before installing them on your main workstation. # Installation First we will install [NVM](https://github.com/creationix/nvm) (Node Version Manager), a batch script that can install and manage multiple Node.js versions. You can use the curl command to download and run the installation script for nvm: **sudo curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash** During the installation, you may see some error messages: *Failed to download 'https://raw.githubusercontent.com/creationix/nvm/v0.31.4/nvm-exec' bash: line 293: /nvm.sh: No such file or directory* You should be able to safely ignore these errors. Close the terminal window and re-open it. Type the command: **nvm** https://i.imgsafe.org/bd3aa369bd.png If you see the nvm help, then it has been installed successfully. Now you can install Node.js using NVM: **nvm install 5** (Truffle recommends at least version 5) Next, we need to install npm (a package manager for Node.js). We will use it to install testrpc and Truffle: **sudo apt-get install npm** Now we can use npm to install testrpc, a Node.js Ethereum client that mimics a real Ethereum node: **npm install -g ethereumjs-testrpc** In order to install Truffle, we also need to install git (and the build-essential package if it's not installed by default). **sudo apt-get install git** **sudo apt-get install build-essential** Now we can install Truffle using npm: **sudo npm install -g truffle** Are you getting any error messages? Check the Troubleshooting section below. # Start Testrpc and Initialize Truffle To start testrpc, open a command terminal and type **testrpc**. It will run in background and wait for connections. https://i.imgsafe.org/bd442a3e01.png Next, open a new terminal window, create a project folder, go into it, and initialize Truffle: **mkdir myproject cd myproject tuffle init** (this command will create a file structure within the current directory) Now you can test the default Truffle project (MetaCoin) by issuing the command: **truffle test** https://i.imgsafe.org/bd4943266b.png You should get three passing tests. If so, you've successfully installed Truffle and testrpc! # Troubleshooting Potential error messages during Truffle installation: *npm ERR! Linux 4.4.0-34-generic* *npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "truffle"* *npm ERR! node v4.2.6* *npm ERR! npm v3.5.2* *npm ERR! file sh* *npm ERR! code ELIFECYCLE* *npm ERR! errno ENOENT* *npm ERR! syscall spawn* *npm ERR! deasync@0.1.7 install: `node ./build.js`* *npm ERR! spawn ENOENT* *npm ERR! * *npm ERR! Failed at the deasync@0.1.7 install script 'node ./build.js'.* *npm ERR! Make sure you have the latest version of node.js and npm installed.* Why is npm reporting node v4.2.6 after we just installed version 5? Ubuntu may come with an older version of nodejs installed by default. Remove it and then try the installation again: Check if you already have nodejs installed: **nodejs --version** To remove it: **sudo apt-get purge nodejs** Having any other problems installing Truffle? Check out the [issues on Github](https://github.com/ConsenSys/truffle/issues)
author | brennanhm |
---|---|
permlink | ethereum-smart-contract-testing-installing-truffle-and-testrpc |
category | ethereum |
json_metadata | {"tags":["ethereum","contract","truffle","testrpc","blockchain"],"links":["http://truffle.readthedocs.io/en/latest/"]} |
created | 2016-08-11 01:50:15 |
last_update | 2016-08-11 01:50:15 |
depth | 0 |
children | 6 |
last_payout | 2016-09-10 15:44:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.028 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 3,891 |
author_reputation | 35,652,247,840,582 |
root_title | "Ethereum Smart Contract Testing - Installing Truffle and Testrpc" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 737,640 |
net_rshares | 41,451,792,356 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
brennanhm | 0 | 31,391,128,908 | 100% | ||
dasha | 0 | 7,485,448,083 | 100% | ||
owdy | 0 | 2,274,660,426 | 100% | ||
callforsanity | 0 | 0 | 100% | ||
hiroshi | 0 | 113,268,658 | 100% | ||
takenbtc | 0 | 187,286,281 | 100% | ||
gamerholic | 0 | 0 | 100% | ||
nyceyes | 0 | 0 | 100% | ||
shaw1 | 0 | 0 | 100% | ||
teddy2 | 0 | 0 | 100% | ||
klen.civil | 0 | 0 | 100% | ||
shinsyotta | 0 | 0 | 100% | ||
tiger746sg | 0 | 0 | 100% | ||
kelsier | 0 | 0 | 100% | ||
hashank | 0 | 0 | 100% | ||
alextuteu | 0 | 0 | 100% | ||
yalb | 0 | 0 | 100% | ||
smartweaver | 0 | 0 | 0% |
author | hiroshi |
---|---|
permlink | re-brennanhm-ethereum-smart-contract-testing-installing-truffle-and-testrpc-20160811t053604140z |
category | ethereum |
json_metadata | {"tags":["ethereum"]} |
created | 2016-08-11 05:36:03 |
last_update | 2016-08-11 05:37:27 |
depth | 1 |
children | 0 |
last_payout | 2016-09-10 15:44:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.018 HBD |
curator_payout_value | 0.002 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 56 |
author_reputation | 966,644,335 |
root_title | "Ethereum Smart Contract Testing - Installing Truffle and Testrpc" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 740,438 |
net_rshares | 31,391,713,771 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
brennanhm | 0 | 31,391,713,771 | 100% | ||
nyceyes | 0 | 0 | 100% |
I really needed to see this article. But This testrpc thing is never working. I wish they had more support!
author | khuziyad |
---|---|
permlink | re-brennanhm-ethereum-smart-contract-testing-installing-truffle-and-testrpc-20170825t022259679z |
category | ethereum |
json_metadata | {"tags":["ethereum"],"app":"steemit/0.1"} |
created | 2017-08-25 02:23:00 |
last_update | 2017-08-25 02:23:00 |
depth | 1 |
children | 0 |
last_payout | 2017-09-01 02:23:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 107 |
author_reputation | 27,573,572,663 |
root_title | "Ethereum Smart Contract Testing - Installing Truffle and Testrpc" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,796,908 |
net_rshares | 0 |
thanks for you shering
author | klen.civil |
---|---|
permlink | re-brennanhm-ethereum-smart-contract-testing-installing-truffle-and-testrpc-20170805t173254531z |
category | ethereum |
json_metadata | {"tags":["ethereum"],"app":"steemit/0.1"} |
created | 2017-08-09 09:44:36 |
last_update | 2017-08-09 09:44:36 |
depth | 1 |
children | 0 |
last_payout | 2017-08-16 09:44:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 22 |
author_reputation | 4,581,233,980,707 |
root_title | "Ethereum Smart Contract Testing - Installing Truffle and Testrpc" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 11,267,805 |
net_rshares | 0 |
I'm about a year late to this party, but I *really* appreciate your awesome guide! Running Debian 9, myself, so for the record peeps, if you download Nodejs elsewhere, the rest of the instructions work like a charm. Thanks again for taking the time to make this guide!
author | shaw1 |
---|---|
permlink | re-brennanhm-ethereum-smart-contract-testing-installing-truffle-and-testrpc-20170818t205647847z |
category | ethereum |
json_metadata | {"tags":["ethereum"],"app":"steemit/0.1"} |
created | 2017-08-18 20:56:54 |
last_update | 2017-08-18 20:56:54 |
depth | 1 |
children | 0 |
last_payout | 2017-08-25 20:56:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 270 |
author_reputation | 348,055,389,541 |
root_title | "Ethereum Smart Contract Testing - Installing Truffle and Testrpc" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,208,538 |
net_rshares | 0 |
Congratulations @brennanhm! You have completed some achievement on Steemit and have been rewarded with new badge(s) : [](http://steemitboard.com/@brennanhm) Award for the number of upvotes Click on any badge to view your own Board of Honor on SteemitBoard. For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard) If you no longer want to receive notifications, reply to this comment with the word `STOP` > By upvoting this notification, you can help all Steemit users. Learn how [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
author | steemitboard |
---|---|
permlink | steemitboard-notify-brennanhm-20170729t081329000z |
category | ethereum |
json_metadata | {"image":["https://steemitboard.com/img/notifications.png"]} |
created | 2017-07-29 08:13:27 |
last_update | 2017-07-29 08:13:27 |
depth | 1 |
children | 0 |
last_payout | 2017-08-05 08:13:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 688 |
author_reputation | 38,975,615,169,260 |
root_title | "Ethereum Smart Contract Testing - Installing Truffle and Testrpc" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 10,097,437 |
net_rshares | 0 |
Congratulations @brennanhm! You have completed some achievement on Steemit and have been rewarded with new badge(s) : [](http://steemitboard.com/@brennanhm) Award for the number of upvotes Click on any badge to view your own Board of Honor on SteemitBoard. For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard) If you no longer want to receive notifications, reply to this comment with the word `STOP` > By upvoting this notification, you can help all Steemit users. Learn how [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
author | steemitboard |
---|---|
permlink | steemitboard-notify-brennanhm-20170813t082529000z |
category | ethereum |
json_metadata | {"image":["https://steemitboard.com/img/notifications.png"]} |
created | 2017-08-13 08:25:27 |
last_update | 2017-08-13 08:25:27 |
depth | 1 |
children | 0 |
last_payout | 2017-08-20 08:25:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 688 |
author_reputation | 38,975,615,169,260 |
root_title | "Ethereum Smart Contract Testing - Installing Truffle and Testrpc" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 11,669,492 |
net_rshares | 0 |