Truffle Introduction

Hi Dan-i Please see attach

Screen Shot 2021-07-05 at 10.56.12 AM

Hey @chim4us

Please update truffle to the latest version, if the pkg is installed globally sudo npm i -g truffle.
If the pkg is installed locally in your repo npm i truffle.
Once done run truffle --version to make sure its updated (version should be 5.3.14).

Keep me posted,
Dani

2 Likes

Thanks so much it worked.
So this means i have to be updating my truffle

2 Likes

Anyone elses computer poo its pants when they changed the default compiler version and recompile?

But then compiles successfully :smile:

Hey all,

I am running into an issue where I get the error:

truffle(develop)> let instance = await helloworld.deployed()
Uncaught ReferenceError: global is not defined
at evalmachine.:2:19

global isn’t defined. At first I was running into trouble getting things to compile because solc was the wrong version but i managed to figure that one out by myself.

already missing remix’s simplicity but excited to be playing with the big boy tools.

I’ve managed to get Visual studio and the required plugins installed but its definitively a bit tricky following Phillip on windows and then translating the subtle differences. Any pro tips for VScode on linux/chromebook are also appreciated :slight_smile:

Hope this finds you well,

Ben

1 Like

Hey @ImmMeta, hope you are ok.

It might be an issue on your truffle installation, you can try follow this guide:

Carlos Z

Hey @ImmMeta

Follow this post: Learning Truffle

i try deploying the contract i made but it giving me an error pls what should i do

pragma solidity 0.7.5;
contract BSShareQ{


    mapping(address => uint256)balance;
    mapping(uint256 => uint256) public referralreward;
    mapping(address => uint256) public userreferralbonus;


    address public owner;
    address payable public projectFee;
    address payable  public withdrawalFEE;
    address payable public supportFEe;

    uint256 public minimiuminvestedAmount;
    uint256 public numberinvestors;
    uint256 public deadline;
    uint256 public goal;
 

    uint256 public total_invested;
    uint256 public total_withdrawn;
    uint256 public total_investors;
    uint256 public total_referral_bonus;

    

    constructor(){
        owner = msg.sender;
        minimiuminvestedAmount = 6300000000000000;
        projectFee = msg.sender;
        withdrawalFEE = msg.sender;
        supportFEe = msg.sender;
    }


    function deposit() public payable returns(uint256){
        require(msg.value >= minimiuminvestedAmount);
     balance[msg.sender] += msg.value;

     return balance[msg.sender];   
     if(balance[msg.sender] == 0){


            numberinvestors++;
        }
        balance[msg.sender] += msg.value;
         
      supportFEe.transfer(msg.value * 5 / 100);
        projectFee.transfer(msg.value * 3 / 100);
    }

    
    function withdraw(uint256 amount) public returns(uint256){
        require(balance[msg.sender] >=  amount);
        require(block.timestamp >= block.timestamp + 2592000 seconds && msg.value = msg.value * 140 / 100);
        balance[msg.sender] -= amount;
        msg.sender.transfer(amount);
        balance[msg.sender] = 0;
    }


    function getbalance() public view returns (uint256){
        return address(this).balance;
    }
    
    function transfer(address reciever, uint256 amount) public {
        require(balance[msg.sender] >= amount);
        require(msg.sender != reciever);
        require(owner == msg.sender );


    uint256 previousSenderBalance = balance[msg.sender];
    _transfer(msg.sender , reciever,amount);

    assert(balance[msg.sender] == previousSenderBalance - amount);
    }
    function _transfer(address from, address to, uint256 amount) private{
        balance[from] -= amount;
        balance[to] += amount;

    }
}`Preformatted text`

Hi guys, I would like to know how you solved the issue below after the truffle compile command is used to compile the very first program shown in the video: https://academy.ivanontech.com/lessons/truffle-hello-world

Source file requires different compiler version (current compiler is
0.8.7+commit.e28d00a7.Emscripten.clang) - note that nightly builds are 
considered to be strictly less than the released version

Notice that in this program the compiler solidity 0.8.0 is used, so I am using the same compiler that I verified with the command solc --version, that gave me the output below:

$$ solc, the solidity compiler commandline interface
Version: 0.8.0+commit.c7dfd78e.Darwin.appleclang

and changed in the truffle-config.js file too the version of my compiler

compilers: {
    solc: {
      version: "0.8.0",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      // settings: {          // See the solidity docs for advice about optimization and evmVersion
      //  optimizer: {
      //    enabled: false,
      //    runs: 200
      //  },
      //  evmVersion: "byzantium"
      // }
    }
  },

I also followed what is show in the contents of this article (https://medium.com/blockchangers/how-to-fix-your-truffle-and-solidity-versioning-with-npx-from-npm-51b5fcb0825f) but nothing changed from my end.

Any advise would be highly appreciated it.

1 Like

hey @cgironda change the compiler verion in the truffle config to whatever the veriosn you sepecify in your contracts. try close vs code and your terminal and reopen if its your first time

Thanks for the advise @mcgrane5 but after using the truffle version command I obtain the output below without any other change:

Truffle v5.4.10 (core: 5.4.10)
Solidity - 0.8.0 (solc-js)
Node v14.17.6
Web3.js v1.5.2

Until here everything seems to be working, however the issue below still appears:

Source file requires different compiler version (current compiler is 
0.8.7+commit.e28d00a7.Emscripten.clang) - note that nightly builds are 
considered to be strictly less than the released version

https://ibb.co/wr5MZGs

1 Like

Yeah strange im now bot sure wjy that would be the case. You could try reinstalling truffle thats works sometimes for people. @thecil have you any ideas on how to fox this error

Hi @mcgrane5 thank you for your time checking what I wrote here. I erased everything to start from scratch. So I reinstalled Truffle and followed the same process:

After using the truffle version command I got the output below:

Truffle v5.4.11 (core: 5.4.11)
Solidity v0.5.16 (solc-js)
Node v14.17.6
Web3.js v1.5.2

So after using the commands npm init and Truffle init I changed the version of the compiler in the truffle-config.js file as shown below:

compilers: {
    solc: {
      version: "0.8.0",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      // settings: {          // See the solidity docs for advice about optimization and evmVersion
      //  optimizer: {
      //    enabled: false,
      //    runs: 200
      //  },
      //  evmVersion: "byzantium"
      // }
    }
  },

Then using the truffle version command again I obtained:

Truffle v5.4.11 (core: 5.4.11)
Solidity - 0.8.0 (solc-js)
Node v14.17.6
Web3.js v1.5.2

Finally, after using the truffle compile command I obtained the output below:

Compiling your contracts...
===========================
✔ Fetching solc version list from solc-bin. Attempt #1
✔ Downloading compiler. Attempt #1.
> 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

However, the message below persists when I open my editor and hover the mouse over the line code: pragma solidity 0.8.0;

Source file requires different compiler version (current compiler is
0.8.7+commit.e28d00a7.Emscripten.clang) - note that nightly builds are 
considered to be strictly less than the released version

Apparently I am using the compiler version 0.8.0 but according to the message above I am not.

On the other hand, when the line of code pragma solidity 0.8.0; is changed by pragma solidity ^0.8.0; the message below appears when I hover the mouse over the word pragma:

SPDX license identifier not provided in source file. Before publishing, consider adding a
comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file.
Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. 
Please see https://spdx.org for more information.

I was wondering if the syntax plays some role here, or if something else is happening.

Did you have guys (@mcgrane5, @thecil ) a similar problem before?.
Any help would be appreciate it!

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