Learning Truffle

I just managed to send a transaction from a different address to approve the transfer using the below command:

instance1.approve(0, {from:accounts[2]})

Great! I had exactly the same problem, this works perfectly! Thanks

Hello, I’ve been trying to sort this issue for a while but can’t seem to find the fix. I’ve tried running sudo npm install but still throws this error (EACCES) and says my operating system rejected it and that i don’t have permission to access this file as the current user. Any Ideas??

Screenshot 2021-03-30 at 10.07.50

I managed it with sudo install. I forgot to uninstall the previous installation attempt before my reinstalling with sudo.

2 Likes

This is for the truffle multi-sig wallet assignment to practice using the terminal.
I ran these commands:
truffle compile
truffle develop
migrate

After the migrate command it said deployment failed. Not sure how to fix this issue

Screenshot 2021-03-30 at 16.54.43

Hi @ol_frank

Post your contract ‘Wallet’ and the migration of it so that I can take a look.
Seems like the contract Wallet (most likely its constructor) requires 2 params but you are not sending them.

Cheers,
Dani

Hey Dan,
Wallet contract:

pragma solidity 0.8.3;

contract Wallet{

    address[] public owners;
    uint limit;

    struct Transfer {
        uint amount;
        address payable reciever;
        uint approvals;
        bool hasBeenSent;
        uint id;
    }

    Transfer[] transferRequests;

    event ApprovalRecieved(uint _id, uint _approvals, address _approver);
    event TransferRequestCreated(uint _id, uint _amount, address _initiator, address _receiver);
    event TransferApproved(uint _id);

    mapping(address => mapping(uint => bool))approvals;

    modifier onlyOwners(){
        bool owner = false;
        for(uint i = 0; i < owners.length; i++){
            if(owners[i]== msg.sender){
                owner = true;
            }
        }
        require (owner = true);
        _;
    }

    constructor(address[] memory _owners, uint _limit){
        owners = _owners;
        limit = _limit;
    }

    function deposit()public payable{}

    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));
    }

    function approve(uint _id) public onlyOwners {
        //owner should not be able to approve twice;
        require (approvals[msg.sender][_id] == false);
        //owner should not be able to approve a tx that has already been sent;
        require (transferRequests[_id].hasBeenSent == false);

        emit ApprovalRecieved(_id, transferRequests[_id].approvals, msg.sender);

        approvals[msg.sender][_id] == true;
        transferRequests[_id].approvals++;
        //condition
        if(transferRequests[_id].approvals >= limit){
            transferRequests[_id].hasBeenSent = true;
            transferRequests[_id].reciever.transfer(transferRequests[_id].amount);
            emit TransferApproved(_id);
        }
    }

    function getTransferRequests() public view returns(Transfer[] memory){
        return transferRequests;
    }

    

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

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

Hey @ol_frank

Yup it’s what suggested in my previous post :slight_smile:

Your wallet contract constructor requires two params but your are not sending them.


  constructor(address[] memory _owners, uint _limit){
      owners = _owners;
      limit = _limit;
  }
module.exports = function (deployer) {
  deployer.deploy(Wallet);
};

Screenshot 2021-03-31 at 14.10.15

Give the requested params to your constructor when deploying and will work.

Regards,
Dani

1 Like

Thank you Dan! Appreciate your help

1 Like

Screen Shot 2021-04-02 at 10.41.32 AM

Screen Shot 2021-04-02 at 10.41.53 AM

npm install -g truffle --force did not work.

when i did npm install -g npm: i got this

Screen Shot 2021-04-02 at 10.46.15 AM
Screen Shot 2021-04-02 at 10.46.20 AM

Hi @dan-i!

I have small issue with building NFT game. Its from first video… I have truffle from (npm install -g truffle) Node.js on my computer.
But If I want to compile (truffle_compile) then I have this:
/C/Users/User/Desktop/NFT_GAME/contracts/Token.sol:1:1: Warning: Source file does not specify required compiler version! Consider adding “pragma
solidity ^0.5.16;”

I changed version in truffle-config.js and uncommented compilers, row version and type 0.8.0.
Please, where is problem?

My contract attached…
image

@dan-i
I had everything working fine with Visual Studio Pro but when I try to use the Cmder shell for compiling, it says that truffle is using solc 0.5.16 to compile. Even though I change this to 0.8.3 in the config file, it still errors. I guess I could not use the Cmder shell but any thoughts on why this is happening?

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify “pragma solidity 0.8.3”.
Please update your truffle config or pragma statement(s).
(See https://trufflesuite.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)

I copied this into the truffle - config.js file and it works now


“path”: “soljson-v0.8.3+commit.8d00100c.js”,
“version”: “0.8.3”,
“build”: “commit.8d00100c”,
“longVersion”: “0.8.3+commit.8d00100c”,
“keccak256”: “0x51777116af58223a41aa3016d0bf733bbb0f78ad9ba4bcc36487eba175f65015”,
“sha256”: “0xb5cedfa8de5f9421fbdaccf9fd5038652c2632344b3b68e5278de81e9aeac210”,
“urls”: [
“bzzr://c7d43da1bc5529d2cc311e00579c36dcff258c42b8ed240b6c4e97bd85492a64”,
“dweb:/ipfs/QmWbNMzJryhiZmyifLDQteGPwN4aTgXQB6barBvXYVw975”
]


http://solc-bin.ethereum.org/bin/list.json

…but I have not tried using this with the Cmder shell yet - just with Visual Studio Pro cmd

…also, I was forgetting to remove the comment out lines // on the truffle-config file

…another mistake I might have made…In Cmder shell, I did not use the truffle develop command – not sure if that was the reason why it failed when I switched over to the Cmder shell.

1 Like

Hey @SYN

Make sure that all the inherited contracts have the right solidity version specified.
If you cannot fix, please push your code on Github and share the link so that I can deploy and check.

Regards,
Dani

1 Like

Solved. I don´t know how, but solved. Thanks :slight_smile:

Hello,

I’m working on the Truffle assignment to deploy the multisig wallet. Unfortunately, the contract will not deploy and I keep getting this error. Can anyone help? Is there something that needs to be changed in the contract code to properly deploy this contract in Truffle?
issue_wallet_cannot_deploy_04.05.2021

Hi @MrSeven

Your constructor requires two params but you are sending 0.
Please check my posts above: Learning Truffle

Cheers,
Dani

Hey guys, I need help, I don’t know if truffle was installed or not but I have these errors

image
image
image
image

Many Thanks!!

Hello everyone,

Why can’t I transfer value when I follow Filip’s instruction on the “Value” part of the Truffle category? It shows an error like this

image
image

Thank you!

1 Like

@dan-i
Hello Dan, I managed to deploy the multisig wallet project using truffle but I am sure something is not right. I have repeated code and who know what else. Here is my migration settings:

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

module.exports = function (deployer, accounts) {
  address = ["0xdc6bbc41d7ff0accd096969921067c07cd3b0d37", "0xe8b2ef888b7059907fe4eeed19892aac95c7e961", "0x87710DfA8D5210d21A44bCB9947755DA22f3A707"];
  uint = 2;
  const userAddress = accounts[0,1,2];
  deployer.deploy(Wallet, ["0xdc6bbc41d7ff0accd096969921067c07cd3b0d37", "0xe8b2ef888b7059907fe4eeed19892aac95c7e961", "0x87710DfA8D5210d21A44bCB9947755DA22f3A707"], 2);
  
};

I can apparently deposit into the account but this is what I get when I try to call the get balance functions:

truffle(develop)> await instance.deposit({value: web3.utils.toWei('1', 'ether') } )
{
  tx: '0x82824e27e85b1992eb10e98c1ec2ff7956341b782ef36e23c0982f464908ba42',
  receipt: {
    transactionHash: '0x82824e27e85b1992eb10e98c1ec2ff7956341b782ef36e23c0982f464908ba42',
    transactionIndex: 0,
    blockHash: '0xdf0d85b1bb8e1f035a644706f0f3b6f0ba36bb2155a4db845bba6fa27f642536',
    blockNumber: 10,
    from: '0xdc6bbc41d7ff0accd096969921067c07cd3b0d37',
    to: '0x400b40ab748e0df47ead115e8ac6cb7d6d8e767d',
    gasUsed: 28441,
    cumulativeGasUsed: 28441,
    contractAddress: null,
    logs: [],
    status: true,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    rawLogs: []
  },
  logs: []
}
truffle(develop)> instance.getWalletBalance()
BN {
  negative: 0,
  words: [ 46661632, 5986771, 444, <1 empty item> ],
  length: 3,
  red: null
}
1 Like