Learning Truffle

Hi, I have a problem with the goerli testnet since ropsten is no longer available.
I followed part of Philip’s tutorial on how to migrate our smart contract to ropsten testnet.


Everything works fine as far as the address is concerned and I get some ETH from Alchemy’s FAUCET but I still get this error.


I understand the problem is with the truffle configuration file but I don’t know what I’m missing.
If anyone can help me figure out the problem, I would appreciate it.

Hi i’m trying to install truffle. I have installed the npm but it says there is some issue that needs to be reviewed. Please find the attached file , I look forward to your solution thanks

1 Like

Your truffle installation looks OK, those warning messages are just for the module developers to update their packages, but does not interfere with the usage of truffle, you should be able to use it without any problem :nerd_face:

Try running truffle -v and it should return the version you installed and the list of commands of truffle.

Carlos Z

Hi, I am following the instructions on installing Truffle and everything works quite fine and it looks same as on Filips screen, but in HelloWorld project I do not have Migrations.sol file in contract folder, nor 1_initial_migration.js file in migration folder? But I have those same 3 folders: contracts, migrations and test, but in them I only have .gitkeep files and that is it, so I am not sure why is that and what to do?

You might need to manually add those files to be able to deploy your contracts.

Check this answer which contains the default template for both files.

Carlos Z

1 Like

Apparently you have to use truffle unbox instead of truffle init. Using unbox will give you the migration files, but the truffle-config,js fie will be extremely minimalistic

1 Like

Hi,
I’m trying to use the multisig wallet from remix in truffle, but I don’t know how to deposit ETH into the contract. How is that done?
tnx

1 Like

There are 2 ways, create a deposit function, or use the receive function.

Creating a deposit function will need the account to trigger that method to deposit ETH.

The receive function will allow you to send funds to the contract in the same way you send funds to a wallet.

Receive example:

    event Received(address, uint);
    receive() external payable {
        emit Received(msg.sender, msg.value);
    }

You can read more about that here:
https://blog.soliditylang.org/2020/03/26/fallback-receive-split/

Carlos Z

Hello, I followed the instructions that Filip said in the “truffle hello world” video and put in the npm init and truffle init commands into the terminal while on the hello world folder, but when i opened the folder in vsc i saw this in my folders that truffle made.

i tried running the commands again from the integrated terminal in vsc and the same result occurred, can someone help?

Hi @empty_nutella,
Hope you are doing well.

It seems like the latest version of truffle doesn’t generate the sample Migration.sol or .js files.
These files are just sample files and are not used in the tutorial, so you can proceed to create a hello.sol as shown in the tutorial.

1 Like

ok cool, thanks for the help man, have a good day

2 Likes

Hello, i tried running the truffle compile command on the terminal during the first migrations video and this error popped up, i tried restarting my laptop and even quit VSC and reopened everything and it still wont work, i know that i am connected to the internet so im not sure why this is happening.

Hi @empty_nutella

You can get that error when you have used a compiler version in truffle-config.js that is not available or wrong.

Can you once verify your compiler version in truffle-config.js file?
It should look something like this with your required version number.

  // Configure your compilers
  compilers: {
    solc: {
      version: "0.8.13", // Fetch exact version from solc-bin
    },
  },
1 Like

Hi @JohnVersus, thanks for reaching out to help me again.

The compiler version in truffle-config.js was set to “0.8.17” before, and after i changed it the same issue came up.

  // Configure your compilers
  compilers: {
    solc: {
      version: "0.8.13" // 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 went back to the pragma in the .sol file to change it to the same version and this error popped up.

Hi @empty_nutella

Now if you run truffle compile again it will download the new compiler version mentioned in the truffle-config.js. That should fix the error.:slightly_smiling_face:

sorry it didnt work, i made sure that the compiler version was 0.8.3 and the same error appeared.

Hi @empty_nutella

Running truffle compile command will download the compiler version mentioned in the truffle-config.js.
Another possible reason that could cause the error is an issue with the internet connection. If you have any active VPN or any kind of blockers please disable those.

If that’s not the case try running truffle compile --reset --all command.
This will remove the existing installed compiler and will download the compiler again with the version mentioned in the truffle-config.js.

Please try the above suggestions and let us know if it works.

1 Like

Oh dear, I never noticed your reply. Sorry about that, thanks for replying!

2 Likes

Hi, it’s not clear to me what is going here

contract Helloworld {

    string MESSAGE = "HelloWorld";

    function hello() public view returns (string memory){
        return MESSAGE;
    }

    function setMessage(string memory message) public{
        MESSAGE = message;
    }
}

So if I run instance.setMessage("Hola") and then run instance.hello() the output will be Hola. Is it because the setter function makes a transaction and because of that a global variable changes?

Why the hello() function doesn’t return "HelloWorld", MESSAGE is a local variable inside the hello() function?

Hi @Lane11

MESSAGE value is not a local variable. By using setMessage you are updating the MESSAGE string stored in memory, so this data accessible even after the transactions.
By using hello function you are reading the MESSAGE from the memory.

1 Like