Learning Truffle

Hi @bjamRez

Are you sure accounts[0] has erc20 tokens?
Are you transferring or minting token in that account?

Sorry, please disregard this issue, I tried it again this morning and it all works fine.
I was not doing things in order but now that I am, I am getting the Big Number and I can also return the result as an integer using either the parseInt or the toNumber functions.

Hmmmā€¦ I get this installation warnings even with sudo command.
But when I wrote npm audit fix , it says found 0 vulnerabilities.
Iā€™m using node version 15.8.0, npm version 7.9.0 (on MacOS Big Sur)

Screen Shot 2021-04-13 at 15.48.50

Hi @REGO350

Warnings are normal and should be ignored.
Type truffle -v to verify the installation.
Regards,
Dani

1 Like

Hi Dani,

I am following up your below given instructions but when I call the const res = await instance.getWalletBalance() it says ā€œinstance.getWalletBalance is not a functionā€. What is going wrong?

Schermafbeelding 2021-04-14 om 08.13.41

Schermafbeelding 2021-04-14 om 08.13.12

I took out the slashes i put originally in front of SPDX-License-Identifier: MIT
and Iā€™m not getting any errors or red lines.

But the helloworld migration is not working:
Screen Shot 2021-04-10 at 10.06.58 PM Screen Shot 2021-04-10 at 10.06.48 PM
Screen Shot 2021-04-11 at 9.35.49 AM
[/quote]

Hey there, make sure your config file looks something like this:

compilers: {
    solc: {
      version: "0.8.3",    // 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"
      // }
    }
  },

here is what my contract looks like:

pragma solidity 0.8.3;
// SPDX-License-Identifier: MIT

contract Helloworld {

  string message = "Hello World Again";

  function setMessage(string memory newMessage) public payable { // this setter func; not a view func...makes a transaction to the blockchain
    message = newMessage;
  }
  function hello() public view returns(string memory) {
    return message; // this view func makes a call; no transaction
  }
}
1 Like

Iā€™m trying to create the HelloWorld.json file in the build/contracts directory with the truffle compile command but I donā€™t see any json files besides Migrations.json.

How do I fix this?

This is the hello.sol file

// SPDX-License-Identifier: jessiej
pragma solidity 0.8.0; 

contract HelloWorld { 

    function hello() public pure returns (string memory) { 
        return "Hello world"; 
    }
}

And this is my 2_hello_migration.js file

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

module.exports = function (deployer) {
  deployer.deploy(HelloWorld);
};

Hi,

I am trying to create an instance for the wallet contract but cannot do it. Could you please help me with the following error?

image

Please note this might be related to the migration of the contract --> when migrating the contract I get this
image

My migration file is as follows
image

@thecil @dan-i

thank you it worked! Although, I still donā€™t get the difference between transaction vs call.

My notes from Filip:

truffle(develop)> instance.setMessage.call("Yet a new, new message") // just gets data from the blockchain - no transactions made to the blockchain - - "not comitting anything to the blockchain"
'Yet a new, new message'

// here, truffle actually writes to the blockchain and we now get returned the new message
// this is now a transaction
truffle(develop)> instance.setMessage("new messge6666")
truffle(develop)> instance.hello()
'new messge6666'
2 Likes

Also after Iā€™ve deploy something onto test net is it possible to delete it?

Hello, I would like to know what ā€œ^ā€ symbol before the version means, and if I need it, thank you. ex: ^0.8.0 .

Also, potential gas consumption?

Hey @thomascarl

Do you have a function getWalletBalance in your contract?

Cheers,
Dani

Hi @inzhagey

From your posts I am not sure if youā€™ve found out what the issue is.
Let me know if you still need assistance.

Cheers,
Dani

Hi @jrdefideveloper

You donā€™t need to create the HelloWorld.json file in the build/contracts because that is created by truffle automatically as soon as you deploy your contract.

The migration file you posted looks correct, therefore I want to be sure you are running the right commands.

  • Make sure that all your files are saved;
  • Using your terminal navigate into your project root directory;
  • Run truffle develop;
  • Run truffle migrate --reset;

Post a screenshot of the results and also your contract code if something fails.

Cheers,
Dani

Hi @jrdefideveloper

You cannot delete a contract once it has been deployed.
You could kill it if you coded the function selfdestruct.

Cheers,
Dani

Hi @Bripeachy

It means that your contract can be compiled with any Solidity 0.8 version (0.8.1, 0.8.4 etc)

Cheers,
Dani

It seams as if truffle should have its own section. I have no idea how to use it and apparently its extremely important to blockchain development. Im trying to read from the website but they dont explain exactly what truffle is they just tell you how to use it. I understand that as a real programmer utilizing a runtime environment is probably 2nd nature to you but you guys cant expect someone with no prior programming experience to understand truffle given only the information provided in this course. Truffle should be an entire course in itself. So now im having to go to another academy to learn truffle so i can understand this course better and even then nobody is explainimg it in the detail that they explain programming using remix. If you guys know of any good readimg materials on truffle please let me know because everything ive found so far dosnt actually explain the basics of truffle they jist assume you already know how to use it and explains the plugins

Hello @dan-i

I have similar issue, tried with your idea, not working yet.

My migration:

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

module.exports = function (deployer, accounts) {

  address = ["0x5B38Da6a701c568545dCfcB03FcB875f56beddC4","0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2","0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db"];

  uint = 2;

  const userAddress = accounts [0,1,2];

  deployer.deploy(Wallet, ["0x5B38Da6a701c568545dCfcB03FcB875f56beddC4","0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2","0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db"], 2 );

};

And this is what I want to send:

await instance.createTransfer(10000, '0xEA1AFdB05fd89c2C61186b28665085F214D25A39' , {from:accounts["0x5B38Da6a701c568545dCfcB03FcB875f56beddC"]})

Is this because in the constructor I added 3 different addresses than which is coming up in truffle when I type in accounts?

Thanks for the help in advance as always.
[/quote]