Truffle Introduction

Hi guys, as an update to this issue:

I verified that the solidity compiler version used globally (using the flag -g) by truffle:

npm -g ls | grep solc
├─┬ [email protected]

At the beginning, I used the solc-select use 0.8.0 command to make this switch:

Switched global version to 0.8.0

The compilation after using the truffle compile command is giving me:

Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Artifacts written to /Users/home/Documents/projects/IvanOnTech/ESC_201/hello_world/build/contracts
> Compiled successfully using:
   - solc: 0.8.0+commit.c7dfd78e.Emscripten.clang

Since I am compiling locally, I don’t understand why the global compiler is triggered in my editor.

By specifying the compiler version in my editor, I couldn’t solve the issue either.
So I still having this https://ibb.co/wr5MZGs

1 Like

Hey @cgironda. Ohhhh ok i see. You dont need to worry at all about the ted solidity error. Thats fine as long as you can run truffle migrate or truffle compile successfully you have done then thats fine. The only reason that error shows is because you are specifying to use a diff solidity version that that of what you installed.

Hi @mcgrane5, thanks for your comment. Yeah, I notice that but I can not configure it. I can run truffle compile but not truffle migrate.

I always get the error below and I can not find how to overcome this issue either.

throw new Error("Could not find artifacts for " + import_path +
" from any sources");

Any idea?. Thanks!

1 Like

Hey @cgironda, hope you are ok.

Could you please share your migration file in the following way?

Carlos Z

Hi @thecil, thanks for your reply.

Actually, there is nothing else to show than what is described in my second post. Every step was followed from the video: https://academy.ivanontech.com/lessons/truffle-hello-world.

Is that what you asked for?

Hi @mcgrane5, I haven’t seen that command yet. What is it for?

hey @cgironda do not mind that last comment i was mstaken

@mcgrane5 anyways thank you!

Hello.

I had have a problem with compiling on my PC. I followed the same steps as in the videos. When I try to compile a simple helloworld contract I get the following output but nothing more.

C:\Users\Admin\Webdev\solidity\eth201project>truffle compile
Compiling your contracts...
===========================
√ Fetching solc version list from solc-bin. Attempt #1

After that I got no further feedback. I then just closed VS Code. If I try to compile now I get the following message.

C:\Users\Admin\Webdev\solidity>truffle compile
Could not find suitable configuration file.
Truffle v5.4.29 (core: 5.4.29)
Node v12.0.0

I use solidity version 0.8.0 in both contract and truffle config file. But I also still get this error message.

[{
	"resource": "/c:/Users/Admin/Webdev/solidity/eth201project/contracts/hello.sol",
	"owner": "_generated_diagnostic_collection_name_#1",
	"severity": 8,
	"message": "Source file requires different compiler version (current compiler is 0.8.11+commit.d7f03943.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version",
	"startLineNumber": 2,
	"startColumn": 1,
	"endLineNumber": 2,
	"endColumn": 23
}]

Thanks in advance for your help

Edit: I uninstalled truffle and wnated to reinstall it. Now I get the following error messages wehn I try to install:

C:\Users\Admin>npm install -g truffle
npm does not support Node.js v12.0.0
You should probably upgrade to a newer version of node as we
can't make any promises that npm will work with this version.
You can find the latest version at https://nodejs.org/
C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\lib\utils\log-file.js:48
    maxLogsPerFile = 50_000,
                     ^^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:703:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\lib\npm.js:15:17)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
1 Like

Hello sir , I just install truffle and just do a small contract compile it it shows error

"ParserError: Expected ‘{’ but got ‘return’
–> project:/contracts/nft.sol:4:36:
|
4 | function nft () public pure return(string memory) {
| ^^^^^^
"

pragma solidity 0.8.0;
contract nft {  

    function nft ()  public   pure return(string memory) {

    return "nft ";
    }
}

What worked for me:

if you try running this command “npm cache clean -f” and it doesn’t work,

on your windows machine(mine is windows 10) access the “npm” and “npm-cache” folders in this location “~\AppData\Roaming”

delete these two folders “npm” and “npm-cache”.

go to your windows search bar and search for Node, right click to open file location, run the uninstaller to uninstall NodeJs.

then visit nodejs.org and download and install node again, if you’ve already downloaded it, visit the folder where you downloaded it to reinstall it.

after installation, check your version of npm by typing “npm -v” on your command terminal to see the new updated version of npm installed on your machine.

now you’re all set, Happy coding.

SOURCE: https://stackoverflow.com/questions/56805007/npm-warn-npm-does-not-support-node-js-v12-4-0

Hope this helps, if not, let me know to find another probable solution :nerd_face:

Carlos Z

1 Like

Should be returns on the function header, the keyword return is reserved to the function body.

Carlos Z

@thecil Thanks for your help.
This seemed to help. This time I also got stuck at this part.

C:\Users\Admin\Webdev\solidity\eth201project>truffle compile
Compiling your contracts...
===========================
√ Fetching solc version list from solc-bin. Attempt #1

But after some more seconds a simple test contract compiled successfully.

1 Like

Another problem I encountered was the following. I also had a different reslut than in the video concerning Big Number.

truffle(develop)> result.toNumber()
Thrown:
evalmachine.<anonymous>:0
result.toNumber()
^

ReferenceError: result is not defined
    at evalmachine.<anonymous>:0:1
    at sigintHandlersWrap (vm.js:276:15)
    at Script.runInContext (vm.js:131:14)
    at runScript (C:\Users\Admin\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:364:1)
    at Console.interpret (C:\Users\Admin\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\console.js:379:1)
    at bound (domain.js:415:14)
    at REPLServer.runBound [as eval] (domain.js:428:12)
    at REPLServer.onLine (repl.js:665:10)
    at REPLServer.emit (events.js:196:13)
    at REPLServer.EventEmitter.emit (domain.js:471:20)