Hi @inzhagey
Run npm i truffle
and follow this faq: FAQ - How to downgrade Node.Js
Keep us posted,
Dani
Hi @inzhagey
Run npm i truffle
and follow this faq: FAQ - How to downgrade Node.Js
Keep us posted,
Dani
Hello everyone, It seems that I am encountering 2 issues here any help would be great I updated to the new truffle version but didnât work out⌠So it actually seems that the abicoder v2 is not supported, and also my constructor is not working⌠Thanks a lot for any help !
/C/Users/kilia/OneDrive/Bureau/testingMultiSigTruffle/truffleTraining/contracts/multiSig.sol:3:1: SyntaxError: Unknown pragma "abicoder"
pragma abicoder v2;
^-----------------^
,/C/Users/kilia/OneDrive/Bureau/testingMultiSigTruffle/truffleTraining/contracts/multiSig.sol:34:5: SyntaxError: No visibility specified. Did you intend to add "public"?
constructor(address[] memory _owners, uint _limit) {
^ (Relevant source part starts here and spans across multiple lines).
,/C/Users/kilia/OneDrive/Bureau/testingMultiSigTruffle/truffleTraining/contracts/multiSig.sol:74:57: TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
function getTransferRequests() public view returns (Transfer[] memory){
^---------------^
Compilation failed. See above.
Here is the code my terminal gives me
Hey @Tumbleur
Are you maybe use Solidity 0.8 or higher? In this case if I am remember correctly the abicoder is active by default. Give it a try, if it does not work post the full contract here.
Cheers,
Dani
While migrating my MultiSig wallet I am running into an error for my contract. Here is listed my code and the error message I am receiving:
// SPDX-License-Identifier: Niko
pragma solidity 0.8.4;
pragma abicoder v2;
contract Wallet {
address[] private 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 ownerTest = false;
for(uint n = 0; n < owners.length; ++n){
if(owners[n] == msg.sender){
ownerTest = true;
}
}
require(ownerTest == 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 {
address(this).balance;
}
function getBalance() public view returns (uint){
return (address(this).balance);
}
//Create an instance of the Transfer struct and add it to the transferRequests array
function createTransfer(uint _amount, address payable _receiver) public onlyOwners {
uint newTransferID = transferRequests.length;
Transfer memory newTransfer = Transfer(_amount, _receiver, 0, false, newTransferID);
transferRequests.push(newTransfer);
emit TransferRequestCreated(newTransferID, _amount, msg.sender, _receiver);
}
//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] != true);
require(transferRequests[_id].hasBeenSent != true);
approvals[msg.sender][_id] = true;
transferRequests[_id].approvals += 1;
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);
}
}
function getTransferRequests() public view returns (Transfer[] memory){
return transferRequests;
}
}
Here is my migration code just in case:
const Wallet = artifacts.require("Wallet");
module.exports = function (deployer) {
deployer.deploy(Wallet);
};
Alright I did that and it worked, I now have v10.21.0. In my contracts folder, the token file is still red and shows a red line under pragma solidity >=0.6.0 < 0.8.3;
What should i do now
Your contract have a constructor that requires some arguments to initialize the contract.
Carlos Z
Hi @inzhagey
In my contracts folder, the token file is still red and shows a red line under pragma solidity >=0.6.0 < 0.8.3;
Are you using Visual Studio Code? In case you do thatâs just a warning from the compiler but you should be able to deploy your contract.
If the issue youâre reporting looks like my screenshot below, proceed as follow:
Right click on the pragma statement;
Select âChange workspace compiler version (Remote)â
Now select a compiler version in according to your pragma statement.
The red line will disappear.
Cheers,
Dani
Yay that worked though I deleted the node_modules folder completely as you said and now I canât do the import which is why the error showed up Do I add it back in again and if so how would I do that?
Hi @inzhagey
The error is telling you that the path to the file you are importing is wrong.
If I am not wrong, ERC20capped.sol
is inside the extensions
folder.
Fix the path to the file and will work.
Cheers,
Dani
I went in node_modules but mine has way more folders and I canât find the token folder. Is there another way to find if I have the ERC20capped.sol file
So is there a way to enter those arguments in so that the contract can run or do I delete the constructor as a whole?
I have been trying to use the deployer.deploy() to enter the constructor arguments, but it is not working for some reason. How are you supposed to phrase it to work? I have tried the following outputs but to no avail:
deployer.deploy(Wallet, [â0x3a09085882f71735059906d0c215a8c3cb9e840câ], 3)
Wallet.deploy(["0x3a09085882f71735059906d0c215a8c3cb9e840câ], 3)
My terminal doesnât even recognize the deployer.deploy()
Here are some of the errors I am experiencing:
Is this supposed to go in the Migrations contract or the original contract with the code?
Hi @inzhagey
You have to follow the path folder by folder.
node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol
Hi @DJaySplash
You have to specify the constructor arguments in your migration.
deployed.deploy(Contract, argument1, argument2);
Cheers,
Dani
Oh ok, i found it,
the error went away for this line
import ââŚ/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Capped.solâ;
Though this appears
Hi @William
The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
You have to use sudo
.
Run sudo npm i -g truffle
what are the consequences of having to run SUDO? Does using Ivanâs âMoralisâ skip all of this?
Hi @William
Sudo is used to run a command as admin: https://en.wikipedia.org/wiki/Sudo
Moralis is not related to the way you install software on your pc.
Cheers,
Dani