How to install and use truffle on Ubuntu

Hi, is there anyone who can help with the above issue? I’m trying to learn to use truffle on my Ubuntu v 20.04 but its not working out.

Any help is appreciated.

Perhaps you have already read this:

1 Like

Have you tried to use ubuntu 16.04 instead of 20.04?

Hi, let me try this out

No, I have not., does it work better on 16.04?

Hello sir, maybe this guide could help you to install it over ubuntu 18.04.

Ubuntu 16.04 is a very unstable version, also a very old one, so at least I could suggest to use version 18.04.

Hope you find this useful.
If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Hello., thank you for this., let me check it out and get back to you!

1 Like

Hello., the link you shared was of great help., I managed to get both truffle and ganache working on my system and even compiled a helloworld contract.
However I am facing issues in deploying my helloworld contract., its throwing up an error that I do not understand., here’s a screenshot, have a look., I hope you can help. Thanks in advance!

Hi Mucha_Julius,

You should use HelloWorld instead of helloworld. But in your ganache screenshot, it seems that HelloWorld contract is not deployed. Try to use a migration file (like 1_initial_migration.js in migrations folder) for deploying your contract on local testnet.

Hi, could you please expand on that.,
I have tried changing the deployer.deploy to “HelloWorld” but it returns error "sender account not recognized
And if I leave it as is, it throws reference error HelloWorld is not defined



It seems that your .sol file is named helloworld.sol, but the smart contract name inside is HelloWorld. You should use the contract name (here HelloWorld) to call deployed function.

To deploy in ganache you can just use the truffle migrate command.
Don’t hesitate to relaunch ganache and truffle console to have a clean environment before using truffle command.

Its great to see you progess.
Regarding your error, technically this happens because you’re trying to send a transaction from an address which the node(or ganache) does not know the private key of.
Make sure the account is added to ganache.

I changed it to “HelloWorld.sol” should I change the name in the 1_initial_migration.js to HelloWorld.sol as well?

Hi, thank you for your response
Kindly explain

artifacts.require(“CONTRACT NAME”) will check in all .sol file if he can find a smart contract matching the contract name, so you have to put the smart contract name inside the require.

1 Like

Hi, need use the contract as same as what the holloworld.sol has.
try this:
const HelloWorld = artifacts.require(“HelloWorld”);

1 Like

Hi., I tried this and this is the error I got

Try to use quote.

Looks like you missing or confusing the original initial deploy file 1_initial_xxxxx.js and your contract deploy file.
There are two files in the directory /migrations. The first is filename as 1_initial_migration.js you keep it no any change after truffle init. The second is filename as 2_deploy_helloword.js, the you can give any filename you want, however the filename should be with beginning 2_ . It is your smart contract deployment file.
Hopefully, it helps you

1 Like

Hello., thank you for the advice., this seems to have been what was disturbing me., I have finally managed to deploy the contract after adding the 2_deploy_helloworld.js file…,

So., everytime I want to deploy a new contract I have to create a new deploy.js file., is that right?