Learning Truffle

Hey @AX07

It seems like you are not running a local blockchain therefore Truffle does not know where to connect.

Run truffle develop
Then migrate --reset

Keep me posted!
Dani

im getting this now
image
i cant do “truffle develop” because it gets stuck, so i did the “truffle --reset” and then i compiled and it says everything is up to date, and then when i migrate it shows that message…
But that file path has nothing to do where the actual file is.

That looks like a truffle related issue, update truffle by running sudo npm i -g truffle

sudo : The term ‘sudo’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1

  • sudo npm i -g truffle
  •   + CategoryInfo          : ObjectNotFound: (sudo:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

should i uninstall and download again??

You are probably using windows, try only with npm i -g truffle

worked and got this
image

That’s ok, try to deploy your project

1 Like

@dan-i
Did you even take 10 seconds to read what I wrote or look at the screenshots I took the time to upload?

Hey @Zaqoy

You got warnings during the installation of truffle, but those can usually be ignore.
Do you still get the same error as before (Pointer_stringify is not a function) when deploying your project?

@dan-i
You’re confusing me with the wrong person. Don’t worry about it, I’ll figure it out.

Thank you for your help!!

1 Like

Hey @Zaqoy true I confused you with AX07 :joy: However I sent you a link to an FAQ to fix your problem, you just have to change the compiler version Truffle is using: FAQ - How do change truffle version

Hi Guys,

I’m testing eh Multisig wallet on truffle but I cannot hget it to migrate :slight_smile:

this is the error

Error: *** Deployment Failed ***

“Wallet” – Invalid number of parameters for “undefined”. Got 0 expected 2!.

my migration file looks like this :

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

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

So not sure what’s happening …

1 Like

Hi guys, I’m having problems with the truffle assignment where we have to deploy the multisig wallet code.
It migrates successfully, but then when I type

let instance = await Wallet.deployed()

I get this error:

Error: Wallet has not been deployed to detected network (network/artifact mismatch)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at Function.deployed (/usr/local/lib/node_modules/truffle/build/webpack:/packages/contract/lib/contract/constructorMethods.js:83:1)
    at Object.checkNetworkArtifactMatch (/usr/local/lib/node_modules/truffle/build/webpack:/packages/contract/lib/utils/index.js:245:1)

Could anyone help me out with this? I don’t understand what went wrong. Thank you!

1 Like

Hey @DavidV, @santiago, hope you guys are ok.

Does your multisig wallet contract contains a constructor? Would you please share the code?

@santiago are you trying to deploy into the truffle console? or through migrations? :face_with_monocle:

Carlos Z

HI Thecil,

The wallet is the contract that come from Fillip. So I’m not sure if that should be an issue. I’m also on a M1 Apple MacBook Air.

Here it is below :

pragma solidity 0.7.5;
pragma abicoder v2;

contract Wallet {
    address[] public owners;
    uint limit;
    
    struct Transfer{
        uint amount;
        address payable receiver;
        uint approvals;
        bool hasBeenSent;
        uint id;
    }
    
    event TransferRequestCreated(uint _id, uint _amount, address _initiator, address _receiver);
    event ApprovalReceived(uint _id, uint _approvals, address _approver);
    event TransferApproved(uint _id);

    Transfer[] transferRequests;
    
    mapping(address => mapping(uint => bool)) approvals;
    
    //Should only allow people in the owners list to continue the execution.
    modifier onlyOwners(){
        bool owner = false;
        for(uint i=0; i<owners.length;i++){
            if(owners[i] == msg.sender){
                owner = true;
            }
        }
        require(owner == true);
        _;
    }
    //Should initialize the owners list and the limit 
    constructor(address[] memory _owners, uint _limit) {
        owners = _owners;
        limit = _limit;
    }
    
    //Empty function
    function deposit() public payable {}
    
    //Create an instance of the Transfer struct and add it to the transferRequests array
    function createTransfer(uint _amount, address payable _receiver) public onlyOwners {
        emit TransferRequestCreated(transferRequests.length, _amount, msg.sender, _receiver);
        transferRequests.push(
            Transfer(_amount, _receiver, 0, false, transferRequests.length)
        );
        
    }
    
    //Set your approval for one of the transfer requests.
    //Need to update the Transfer object.
    //Need to update the mapping to record the approval for the msg.sender.
    //When the amount of approvals for a transfer has reached the limit, this function should send the transfer to the recipient.
    //An owner should not be able to vote twice.
    //An owner should not be able to vote on a tranfer request that has already been sent.
    function approve(uint _id) public onlyOwners {
        require(approvals[msg.sender][_id] == false);
        require(transferRequests[_id].hasBeenSent == false);
        
        approvals[msg.sender][_id] = true;
        transferRequests[_id].approvals++;
        
        emit ApprovalReceived(_id, transferRequests[_id].approvals, msg.sender);
        
        if(transferRequests[_id].approvals >= limit){
            transferRequests[_id].hasBeenSent = true;
            transferRequests[_id].receiver.transfer(transferRequests[_id].amount);
            emit TransferApproved(_id);
        }
    }
    
    //Should return all transfer requests
    function getTransferRequests() public view returns (Transfer[] memory){
        return transferRequests;
    }
    
    
}
1 Like

Hi @thecil,
I don’t understand the question. I use truffle develop and then I type in the commands
migrate
and
let instance = await Wallet.deployed()
in the same way Filip does in the instructional video. Everything worked fine when I was following the video trying it on my own. Only now with the multisig wallet assignment I’m getting this error. Not sure if I’m missing something. I also use the same wallet code from Filip’s Github. Thanks for helping!

Santiago

2 Likes

This one happens because your contract have a constructor which require some parameters to initialize properly, Invalid number of parameters for “undefined”. Got 0 expected 2!.

So your migration file should looks like this one, which sent the correct parameters to the constructor and then the contract is inizialited.

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

module.exports = function(deployer, network, accounts) {
    // [multisig constructor] 
    // Should initialize the owners list and the limit 
    // constructor(address[] memory _owners, uint _limit) {
    //     owners = _owners;
    //     limit = _limit;
    // }
    const accountArray = [accounts[0], accounts[1], accounts[2]] 

    deployer.deploy(
      Wallet,
      accountArray, // this is _owners Array
      2 // this is _limit
    );
};

Carlos Z

2 Likes

@santiago, check the post above this one, when you migrate your contract should contain a migration file which is going to deploy the contract when the migrate command is invoked.

while deployed() is used once the contract has been deployed from its migration file (so if none exist, the contract has not been deployed)

Carlos Z

2 Likes