Learning Truffle

For some reason I can use truffle compile in my command prompt, but when I try to run truffle compile in the native Visual Studio Code terminal it tells me ‘truffle’ is not recognized as an internal or external command.

Any ideas? I have tried the command in both the VS Code command prompt and VS Code powershell.

1 Like

Try use CMD instead (windows command prompt), powershell works nice if you configure the the permissions of it, but cmd is a best option since you will find less issues with the terminal.

https://code.visualstudio.com/docs/editor/integrated-terminal

Carlos Z

Hello everyone.
I am having some issues with the migration portion of the course. May be something small that I did on my end. I’m getting an error code when running the second migration file. I am receiving an error code for some reason. Below is an image of the issue that I’m encountering. Thanks.

Hey @jtb, hope you are well.

Could you please share the migration file of the contract? maybe the error is there.

Carlos Z


@thecil

1 Like

artifacts.require("Helloworld");

The problem is that your contract file name is hello.sol so you have to point the artifact to the same filename (or rename the contract, what you prefer). PD: no need for the .sol, just that the artifact points to the proper file name ("hello").

Note: Please share your future code in the following way so i can easily copy/past for quick reviews :nerd_face:
FAQ - How to post code in the forum

Carlos Z
Carlos Z

Hey,
some feedback about ERC20 Coding lecture, I think it is outdated and needs updating. I believe OpenZeppelin and Truffle has updated their software and repeating what Filip does in the video results in different kind of errors that didnt come up back then. I manually modified OpenZeppelin files to be able to get it to compile & recognise the 1000 tokens inputted in the constructor.

I think because of updates you dont need to do result.toNumber() anymore, instead you will see the number directly from balanceOf now.

1 Like

I’ve the same problem man unstalling, unistalling, using --force. No way for going forward. So annoying

maybe the problem is with nodejs
:grimacing:

I’ve been getting this error while trying to compile my smart contracts
I need help please, I’ve tried every possible solution I have seen here

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity ^0.8.0".
Please update your truffle config or pragma statement(s).
(See https://trufflesuite.com/docs/truffle/reference/configuration#compiler-configuration for information on

Take a look from the minute 9:30, https://academy.moralis.io/lessons/truffle-hello-world

you are just forgetting that step in your truffle.config file.

Carlos Z

I’ve done that but it’s not working either

1 Like

I have a little problem with the installation of truffle. Do some of you know a solution? This is only on my laptop. On my desktop PC i followed and did the same steps and did not have any problems.

 78 vulnerabilities (7 low, 49 moderate, 15 high, 7 critical)
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\pauls\AppData\Local\npm-cache\_logs\2021-12-10T17_21_24_266Z-debug.log   
1 Like

Try change your compiler version of solidity in the truffle.config file to ^0.8.0, also you have to check which is the version of your contracts, should be the same that you will use for the truffle.config.

Carlos Z

Hey @PaulS96, hope you are well.

Sorry but the error message does not said too much about why is the error, which repository did you try to install in your laptop? Maybe the npm version on the laptop is different? or must install git? (i mean maybe your just missing one of the programs in your laptop).

Carlos Z

1 Like

i did just that but its not working

I’ve been on this for long
I’ve updated truffle and solc but it isn’t still working

@thecil Hi, I tried to uninstall and reinstall both Truffle and Node.js. This didn´t solve the problem but I managed to fix it with npm i --package-lock-only followed by npm audit fix. This seema to have fixed the problem. If someone has the same problem I hope this is helpful for you.

1 Like

Hi all…I am working on the Truffle assignment. I was able to successfully deploy Wallet.sol with these parameters for the constructor

const Wallet = artifacts.require("Wallet");

const owners = ["0xb572975938f0ca7cafa4b383194873538146b415","0xcd18d7a360a17dbbdbfe63aaab4ca933fbdc0b4c","0xbcd560444eaccb9115b48111cc961330e71852c0"];
const limit = 2

module.exports = function (deployer) {
  deployer.deploy(Wallet, owners, limit);
}

Subsequently, I was able to Create and Approve two Transfer requests:

However, I keep getting an out of gas error with I attempt additional approvals. I’ve tried various combinations of the owners - e.g., truffle(develop)> instance.approve(0, {from: accounts[2]}).

Here is the error:

Any suggestions? Thx!

You might have to use await instance.approve(...) since its an async method to invoke, but i suggest to move forward until you reach unit test, then you can write all this tests for the contract instead of manually doing them on the truffle console

Carlos Z