Thank you so much again Dani! You are my hero
Hi Team,
I am working on the assignment to migrate the multi-sig wallet and trying to passing the owners array of addresses however the only thing that has worked is to hardcode the addresses (taken from the accounts arra( in the deployer function as an array.
Is this the only way or is there a more generic approach where we can use specific accounts from the accounts array referencing the accounts array as âaccounts[0]â for example.
Any advice would be helpful!
Thanks
Sure you can use the array of accounts.
You can do that from your migration file, give it a try if you cannot find the solution post the migration here
Cheers,
Dani
Thanks Dani!
So I did some reading on the truffle website and noticed that I can pass an array of accounts to the module.exports function so I tried something like this:
const Wallet = artifacts.require("Wallet");
module.exports = function (deployer,accounts) {
var numApprovals = 2;
var arr = [accounts[0],accounts[1]];
deployer.deploy(Wallet, arr, numApprovals);
};
But that seemed to fail. I tried a few variations of that but the only one that seemed to work was the following:
const Wallet = artifacts.require("Wallet");
module.exports = function (deployer,accounts) {
var numApprovals = 2;
deployer.deploy(Wallet, ['0xb10934df75f7b1f064cce0c3ae41b4726fa0a7a6','0xb10934df75f7b1f064cce0c3ae41b4726fa0a7a6'], numApprovals);
};
Where those addresses were pulled after I ran the truffle develop command.
Ideally I would like to not have to hardcode them in the deployment script but maybe that is the only way
let me know!
Thanks!
You are almost there
Truffle migration has 3 params: deployer, network and accounts.
Documentation: FAQ - How to post code in the forum
accounts
is the 3rd parameter.
module.exports = function (deployer, network, accounts) {}
Try this way and should work.
Cheers,
Dani
I installed truffle like he said and already had visual studio installed. When it came time to create a new .sol file in visual studio, I found that I had the package.json file, but no Migrations.sol or truffle-config.js. What do I do? I checked my command prompt and it looked the same as what he did.
It looks like I fixed it by unboxing metacoin to my folder. I think unboxing any truffle project would have worked? Anyway I googled for how to use truffle and found a youtube tutorial by our teacher (the same guy) and thatâs where I got the solution.
I am trying to run my multisig wallet on remix and truffle side-by-side. The remix version is running fine, like it did when I first made it. But when I try to use the âAddOwnerâ function (thatâs all Iâve gotten to so far) on truffle, and I use the exact same address as on remix, it says that I have an invalid argument. Why would the function work fine on remix and not on truffle?
Edit: I solved my own problem again. I added single quotes to the address on truffle and it works. I guess they gave me the quotes automatically on remix.
Edit2: Now I have a new question: In remix, I could switch addresses by using a dropdown list. How do I do this in Truffle? I canât test the functionality of a multisig wallet without using multiple addresses.
I have the same problem; Iâm not sure how to switch accounts to do second approval. If you find a solution, please let me know!!
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??
I managed it with sudo install. I forgot to uninstall the previous installation attempt before my reinstalling with sudo.
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
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
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);
};
Give the requested params to your constructor when deploying and will work.
Regards,
Dani
Thank you Dan! Appreciate your help
npm install -g truffle --force did not work.
when i did npm install -g npm: i got this
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âŚ