I tried it and it still does not find it.
The command was right, I found out on other forums and support that I missed npm version manager, so I just installed it in cmd with
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh
And it finally works.
Hi @Jethrodog, I can see you have used Atom before and now Visual Studio Code. I am encountering this issue when trying yo download extensions for Visual Studio Code
First this;
Then this;
When I try download it manually, I get this;
How can you assist me in resolving this issue.
Furthermore, how can I use atom, so as to be able to continue with the course, because I am stuck with this installation.
Thanks.
Thanks I have manage to get it to work by downloading it manually.
Hi guys, I have been able to deploy the MultSig Wallet contract with truffle, I can deposit but I encounter the below error when I try to create a transfer request.
@dan-i, require your assistance on this please and anyone can help me please. Thanks.
Does your transferRequest()
is a payable function? (because you are sending a value to it), if not, you should try web3.utils.toWei('1', 'ether') instead of
{value: …}`.
For unit tests, some times the value should be converted to BigNumber
, or could also be a bug on execution, I have encounter that using web3.utils.toWei()
directly on the argument it could result on an issue like this.
So i could suggest you to try: https://docs.openzeppelin.com/test-helpers/0.5/
Which integrate support for BigNumbers (BN).
Also you could try to calculate the value to send by using a function to calculate the convertion to wei.
// same than using web3.utils.toWei() but in a custom function
let _qtyEth = function(_amount) {
return (web3.utils.toWei(_amount.toString(), "ether"))
}
Then invoce the function like _qtyEth(1)
which will return the value of 1 ether in wei.
Or just use the ether
function from openzepellin, which is basically the same.
const ether = require('@openzeppelin/test-helpers/src/ether');
// ether(1) => returns value on BN wei
Carlos Z
@thecil thanks so much. But I must say that I am a Baby Programmer. I do not understand the Big Number and the Openzeppelin.
However, will you be so kind to take a look at my code with a few modifications I made when trying it out with remix;
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
//pragma abicoder v2;
contract MultiSigWallet {
// ["0x5B38Da6a701c568545dCfcB03FcB875f56beddC4","0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2","0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db"]
address[] public owners;
uint limit;
constructor (address[] memory _owners, uint _limit) {
owners = _owners;
limit = _limit;
}
modifier onlyOwners {
bool owner = false;
for(uint i = 0; i < owners.length; i++){
if(owners[i] == msg.sender){
owner = true;
}
}
require(owner == true);
_;
}
struct Transfer {
uint amount;
address payable to;
uint approval;
bool hasBeenSent;
uint id;
}
Transfer[] transferList;
mapping(address => mapping(uint => bool)) approval;
mapping(address => uint) balance;
event deposited(address from, uint amount);
event transferRequestCreated(uint _id, uint amount, address receiver, address requisitor);
event approved(uint id, uint approval, address approver);
event transferred(uint id);
function deposit() public payable {
require(msg.value >= 10 ether, "Insufficient Amount");
balance[address(this)] += msg.value;
emit deposited(msg.sender, msg.value);
}
function transferRequest(uint _amount, address payable _to) public onlyOwners {
require(_amount != 0, "You cannot send nothing");
require(_amount <= balance[address(this)],"Balance Insufficient");
emit transferRequestCreated(transferList.length,_amount, _to, msg.sender);
Transfer memory createTransfer = Transfer(_amount, _to, 0, false, transferList.length);
transferList.push(createTransfer);
}
function approve(uint _id) public onlyOwners {
require(approval[msg.sender][_id] == false);
require(transferList[_id].hasBeenSent == false);
approval[msg.sender][_id] = true;
transferList[_id].approval++;
emit approved(_id, transferList[_id].approval, msg.sender);
if(transferList[_id].approval >= limit){
transferList[_id].to.transfer(transferList[_id].amount);
transferList[_id].hasBeenSent == true;
balance[address(this)] -= transferList[_id].amount;
//balance[transferList[_id].to] += transferList[_id].amount;
emit transferred(_id);
}
}
function getTransfersList() public view returns (Transfer[] memory){
return transferList;
}
function getBalance() public view returns (uint) {
return balance[address(this)];
}
}
Here is my Migration File as well;
const MultiSigWallet = artifacts.require("MultiSigWallet");
module.exports = function (deployer, accounts) {
const addresses = accounts[0,1,2];
const limit = 2;
deployer.deploy(MultiSigWallet,['0x7a90ef4b00d96ccc2b4f959d5b935cc8693aa62d', '0x34426cf4c9ed3a5f7904f3fbd63ccf7a3146fbf2', '0x329da9adc71843218be1ea57602d7f6f865f2393'],2);
};
Kindly go through it for me and assist me in understanding this.
Thanks.
Paul.
Okay, so despite following what they said about changing my solc to >=0.6.0 < 0.8.0 across all the files, it’s still not working
hey @inzhagey see in your sixth photo there, it says
source file requires different compiler version (current compiler version is 0.8.3.........
in your files you have your pragma solidity as
pragma solidity >=0.6.0 < 0.8.0;
but the message says your current compiler version is 0.8.3. so maybe if you Try changing the above to
pragma solidity >=0.6.0 < 0.8.3;
and see if this works hopfully it does. The other option is to hardcode the compiler version in the truffle-config.js file
hey @Omas. So basically since your code has a constructor that takes arguments which needs to be defined for other functions to be called we need to modify your migrations file which you have already done so that good.
However one change i suggest making is to replace your long list of addresses with the addresses variable you define. It just neater and theres no need to have the big array as you do.
So when you have a constructor that takes in user defined arguments we can can add the constructor parameters as extra arguments to the deploy()
call. This is how they are initialised like you have done. However personally I dont like doing this as much as i can get away with… It would (in my opinion) be better to define a function that is called addUsers( ) which takes in an address as an argument and pushes it to the address array. This we our array is now dynamicaaly sized meaning we can add as many users as times we call the addUsers( ) function.
What you can also do is define a formula for the minimum consesns limit. Like a very simple example would to have limit as
uint limit = owners.length - 1
this is not the best way but its simple enough. However, when executing the createTransfer function you probably should require that you users array has at least 2 users to prevent issues with the above formula. You can take a look at my code here to see how this is implemented. It saves adding all of the extra things to the migrations file
function addUsers(address _owners) public
{
for (uint user = 0; user < owners.length; user++)
{
require(owners[user] != _owners, "Already registered");
}
owners.push(_owners);
//from the current array calculate the value of minimum consensus
limit = owners.length - 1;
}
Now when we go to deploy we can add users and call our getUser func like this
EDIT** carlos and daniele, my question is at the end
For anyone who is doing the testing, most likley your approve function only takes in the transferRequest ID. In remix this is fine because we can just switch accounts at a click of a button. However doing this in truffle is harder maybe theirs not even a way im not sure. But what you can do after you create a transfer is this
if we try this again we will get a revert error as we coded this in the approve function. We could go back and change the arguments to take in the approver address and then require that the address passed in is an owner r something but you can get around it by doing this
This will work and your transfer will go through afterwards. I didnt think this would work because the approve function takes no other arguments and i did not think truffle would figure out what i was trying to do but i tried it anyway and it worked so happy days.
Everything in my tests run perfectly except for one little thing. I have not figured out my getBalance function. Again the fact that we cannot simply change accounts in truffle like we can in remix makes me want to recode the get balance function to take in and address and return the balance. However when i call the balance function i get this
What method call can i do so that this returns the wei value. I tried using .balanceOf, and i tried using a lambda function .then(bn => bn.toNumber( )) and a few other various things but obvioulsy im new enough to truffle and dont know all of the commands yet. @thecil @dan-i any ideas?
I tried that and got the same error after exiting the blockchain and compiling it again
Error: Truffle is currently using solc >=0.6.0 < 0.8.0, but one or more of your contracts specify “pragma solidity ^0.8.0”.
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.)
Compilation failed. See above.
Hey @thomascarl
I have cloned and deployed your contracts, works perfectly on my machine.
Can you try to restart the whole process from scratch?
- Close truffle / ganache;
- cd into your project root directory and run
truffle develop
; - run
truffle migrate --reset
; - run
let link = await Link.deployed()
Should work, let me know.
Cheers,
Dani
Hi @inzhagey
Can you push your project to Github? Will deploy and take a look.
I still think you did not restart truffle, if you don’t do that it will keep compiling with the old truffle version.
Make sure to save all your file, restart truffle and run truffle migrate --reset
Regards,
Dani
Hey @mcgrane5
web3 has a method that converts any number to wei (or any way amount to ether).
This method wants a string as argument.
In your case:
const accountBalance = await instance.getAccountBalance();
// I expect this to return a big number, double check that I don't have your code so I cannot test.
const balanceToWey = await web3.utils.toWei(accountBalance.toString())
console.log(balanceToWei);
Keep me posted,
Dani
hey @inzhagey that is very strange i dont know why that would happen. Maybe your not doing something right or else you have a weird bug. Now i dont know if this will work but i can suggest maybe you try one more thing.
Try uninstalling truffle with
npm uninstall -g truffle
.The version i use is 5.3.2 and everything works for me. So try installing that version using
npm install -g [email protected]
Now I dont know if this will work as im not sure if uninstalling truffle will remove solidity also but maybe its worth a try.
Hi daniele that worked perfectly. I actually changed my getAccountBalance( ) function last night to take in an address (instead of just returning balance of msg.sender), making it similar to the ERC20 contract and then using FIlips mwthod to get the balance worked for me.
Just tried your way there also and it works thanks for that. I think when i was trying yesterday i was missing the “accountBalance.toString()” part to convert to a string. Thanks for that
Evan
.exit
truffle develop
truffle compile
truffle migrate --reset
this is what i’ve been doing, am i missing something?