Truffle Introduction

if we where to create a real contract are we expected to use ganache?
in term of the website are suppose to use an appropriate website rather or we will just create a local one as u have shown in the learns?

Hi @beloved

Ganache is a local blockchain that you use to run and test your smart contracts locally.
When you will deploy contracts that have to be used by other people, you will deploy them in the Ethereum blockchain (testnet first then mainnet).
Same thing for the website. You use localhost to test, but you will deploy in a server in case the website has to be used by other people.

Cheers,
Dani

Hello Filip. Should I wait for the “New” Ethereum 201 course?.. I see the one I’m in has been labeled “Old”. Pls Help

Hi @Coolmaster

The solidity 201 course has been released already but you can still do both as the old one is still a great course and you will learn lots of stuff.
The idea is that the more you learn the better :slight_smile:

Happy learning,
Dani

1 Like

Does anyone know why if I use the .call method on my contract instead of giving me the string I entered in setMessage function it gives me Result {}
Here is my code and the results I get:

pragma solidity 0.8.4;

contract HelloWorld{

    string message = "Hello World!";

    

    function setMessage(string memory newMessage) public payable returns(string memory){

        message = newMessage;

        return message;

    }

    function hello() public view returns(string memory){

        return message;

    }

}

image

1 Like

Hey @DJaySplash

You are using .call() the wrong way.
You cannot use .call() to send transactions, you can just use it to read from the contract.
In order to send a transaction (if you are using web3) you have to use .send().

Keep in mind that, in this case you are not creating a web3 instance of your contract, therefore you just have to send a transaction using the console.

Send tx:

Screenshot 2021-05-17 at 11.46.42

Read:
Screenshot 2021-05-17 at 11.47.09

You will use the web3 method .send() to send a transaction only when you create a web3 instance of your contract.

Cheers,
Dani

1 Like

Thanks that makes more sense!

Hey guys much like i did in the ethereum game programming course, because this course is very old and outdated im going to again write these tutorial style posts on how to fix certain issues that may arise. There were plenty in the eth game prog course and im sure there will be a lot in thus course too.

before i begin i just want to say how every time i hear @filip say gana chiii makes me laugh to myself hahah so funny. anyways with that out of the way…

This first section on truffle is pretty fine because i imagine most people coming after me taking this course have already completed SC 201 [NEW]. However there is one issue that arose for me that Filip doesnt explain and i feel like it could be a common issue for many people. That is the undefined network error. This happens when we enter te truffle console and try to deploy our contracts using ganache. For me this was the error

truferr

Its not even an error message because our contracts were able to compiled nothing failed but we were not able to connect to ganache. To fix this we need to read what the error says and go to our truffle config under the “available networks” section

confi

But what do we put in here. Well all of the details lies within the ganache app. We need to replace the host, network_id and the port with the correct ganache equivalent so that we can connect to our ganache personal blockchain with truffle and thus deploy our code. So going to ganache we can get the network ID and port number easily here

gan

We can see the network id and note that the host number are the digits up until the colon and the number after the colon are for the port number. With that youll be able to compile and deploy.

One other quick thing to mention is dont think youve done something wrong if you dont get a print message statement in your terminal after the video where filip codes a console.log(message) function into the migrations file. This line will actually print but since the function is async we dont know when it will fire so chances are it will print in the middle of your deployment description. So if you dont see it exactly at the command line dont worry you haven’t done it wrong its most likely somewhere in your deployment.

Hello,
I am having issues trying to deploy the MultiSig wallet in truffle.
I have complied the code successfully and created a new 2_wallet_migration.js file. When I try to migrate it fails the deployment with the error "Invalid number of parameters for “undefined”. Got 0 expected 2!.

Not certain how to proceed?

Hi @CMar10

The contract you are migrating in “2_wallet_migration.js” has a constructor that requires two parameters, however you are sending 0.
Check that out.

If you cannot solve post your migration file here.

Cheers,
Dani

In the class video there was no mention of any other steps than adding the contract name in 3 places to the new migration.js file. Did I miss something?

There is a constructor with _owners and _limit parameters. Do these need to be added to the deployer.deploy(Wallet) after Wallet?

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

module.exports = function (deployer) {

  deployer.deploy(Wallet);

};

When trying to complete the section Extending ERC20 I get the following compile error:

TypeError: Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
–> /C/Users/Connie/Documents/Blockchain/Solidity/truffle/token/node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol:26:16:
|
26 | return _cap;
| ^^^^

Compilation failed. See above.

Also, the function _beforeTokenTransfer does not exist in the ERC20Capped.sol file anymore. This must have been updated since the video was made.

What do I need to do to get this to compile?

1 Like

can u share you code ill have a look

This is from the openzeppelin ERC20Capped code

pragma solidity ^0.8.0;

import "../ERC20.sol";

/**

 * @dev Extension of {ERC20} that adds a cap to the supply of tokens.

 */

abstract contract ERC20Capped is ERC20 {

    uint256 immutable private _cap;

    /**

     * @dev Sets the value of the `cap`. This value is immutable, it can only be

     * set once during construction.

     */

    constructor (uint256 cap_) {

        require(cap_ > 0, "ERC20Capped: cap is 0");

        _cap = cap_;

    }

    /**

     * @dev Returns the cap on the token's total supply.

     */

    function cap() public view virtual returns (uint256) {

        return _cap;

    }

    /**

     * @dev See {ERC20-_mint}.

     */

    function _mint(address account, uint256 amount) internal virtual override {

        require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");

        super._mint(account, amount);

    }

}
1 Like

Hey i dont think the error is in that file. that contract works fine for me. In any of your other contracts are you minting in the constructor. If so instead of saying “_mint()” call ERC20._mint(). I think the reason is because the cap var is immutable and thats whats causing the error. I remember in Filips video his version of openzeppelin had the cap var as just private and not immutable thus minitng in the constructor was possible. If you want you can either use the ERC20.mint() or make the cap var not immutable or even you can write a mint function so that your not minitng in the constructor its up to you. For referance See this forum below it shows how to solve the exact error that your code is producing above using the ERC20.mint() way.
https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2580

1 Like

Ok, Thanks for the help. I keep moving forward with the classes hoping this will start to make sense, but at the moment it is just not happening for me.

1 Like

Hello everyone
Im trying to use atom like in the lecture but i cant get it to recognize Solidity language. Is anybody having the same issue? Any tips?

1 Like

hey @Meriem. If your using atom when you launch you should see the welocme page where these options for opning a project or installing packages etc. Choose the install a package option and type in solidity and install it. should work then for you. Let me know if any issues arise

2 Likes

Problem solved. Thanks !

1 Like

I want to compile solidity code got below error

Error: TypeError: soljson.Pointer_stringify is not a function
    at Object.compile (/usr/local/lib/node_modules/truffle/build/webpack:/packages/workflow-compile/legacy/index.js:72:1)
Truffle v5.0.42 (core: 5.0.42)
Node v10.21.0
1 Like