ok now install truffle again. specifically type
npm install [email protected] -g
When I run npm install -g truffle I get his response:
npm WARN deprecated [email protected]: This package is broken and no longer maintained. ‘mkdirp’ itself supports promises now, please switch to that.
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by @ipld/dag-cbor and multiformats
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated @nodefactory/[email protected]: Package is deprecated in favour of @chainsafe/filsnap-adapter
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by @ipld/dag-pb and multiformats
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm WARN deprecated [email protected]: This module has been superseded by the multiformats module
npm WARN deprecated [email protected]: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path C:\Users\micha\AppData\Roaming\npm\node_modules\truffle\node_modules\ganache\node_modules@trufflesuite\bigint-buffer
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.2 found at “C:\Python310\python.exe”
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS checking VS2019 (16.11.32106.194) found at:
npm ERR! gyp ERR! find VS “C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools”
npm ERR! gyp ERR! find VS - found “Visual Studio C++ core features”
npm ERR! gyp ERR! find VS - missing any VC++ toolset
npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the “Desktop development with C++” workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:363:14)
npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:16
npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:520:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16)
npm ERR! gyp ERR! System Windows_NT 10.0.18363
npm ERR! gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” “rebuild”
npm ERR! gyp ERR! cwd C:\Users\micha\AppData\Roaming\npm\node_modules\truffle\node_modules\ganache\node_modules@trufflesuite\bigint-buffer
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\micha\AppData\Local\npm-cache_logs\2022-03-14T16_23_39_556Z-debug-0.log
then try truffle verion again when its done
Thank you it is now working but I have a new problem.
$ truffle migrate
Could not find suitable configuration file.
Truffle v5.4.19 (core: 5.4.19)
Node v16.14.0
I am stuck on this video: https://academy.moralis.io/lessons/web3-js-start-coding
How do I get the result that the teacher gets at 05:04?
Thanks
perfect yes you have succesfully installed truffle now. dont worry about all those messages above there just wanrning and are expected when you install npm packages. as for ypur new error, you need to execute
truffle init
first before you can type truffle migrate --reset or anything.
Compiling your contracts…
Compiling .\contracts\Migrations.sol
Artifacts written to C:\Users\micha\OneDrive\Desktop\Ivan On Tech\NFT Marketplace\build\contracts
Compiled successfully using:
Something went wrong while attempting to connect to the network at http://127.0.0.1:7545. Check your network configuration.
Could not connect to your Ethereum client with the following parameters:
ok can you try running
truffle develop
and then after a few when this command runs then try
truffle compile
I love you thank you so much I have been stuck on this and it has stopped me from doing actual coding for hours.
Truffle migrate now works
no worries at all glad i could help. a little motivation now, youll be glad to know that this step is the hardest for first time users with truffle because if something goes wrong theres so many things that could be the cause of the issue but now that you have truffle working the only thing that will stop you is actual erors in your code which are usuall always easy to debug with a bit of time. anyway happy coding and see you around the forums
Hello all can someone help me out with this error message.
ompiling your contracts...
===========================
> Compiling ./contracts/token.sol
TypeError: Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it.
--> project:/node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol:27:16:
|
27 | return _cap;
| ^^^^
Compilation failed. See above.
truffle(develop)>
This is the contract from @openzeppelin
pragma solidity ^0.8.0;
import "../ERC20.sol";
/**
* @dev Extension of {ERC20} that adds a cap to the supply of tokens.
*/
abstract contract ERC20Capped is ERC20 {
uint256 private immutable _cap;
/**
* @dev Sets the value of the `cap`. This value is immutable, it can only be
* set once during construction.
*/
constructor(uint256 cap_) {
require(cap_ > 0, "ERC20Capped: cap is 0");
_cap = cap_ ;
}
/**
* @dev Returns the cap on the token's total supply.
*/
function cap() public view virtual returns (uint256) {
return _cap;
}
/**
* @dev See {ERC20-_mint}.
*/
function _mint(address account, uint256 amount) internal virtual override {
require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(account, amount);
}
}
or paste code here
hey i think its because cap is immutable in ERC20Capped
thus it cannot be read during the mint process in the constructor. It was done on purpose to lower gas costs. are you trying to mint tokens in the constructor of any of your other files. if so this is why the error is showing
Thanks, I wanted to compile the contract and test, to see if it works. what should I amend to make it compile?
hey everyone, I’m having some errors installing truffle even after trying to reinstall it and tried npm install -g truffle --force. But i get the following errors. Can anyone please help?
Hey guys, anyone knows what’s wrong?
Been trying to install truffle on my machine today (MacOS latest version), but keep getting this errors in the terminal:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/truffle
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/truffle’
npm ERR! [Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/truffle’] {
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘mkdir’,
npm ERR! path: ‘/usr/local/lib/node_modules/truffle’
npm ERR! }
npm ERR!
npm ERR! 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
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/daanboshoven/.npm/_logs/2022-04-11T14_09_30_706Z-debug-0.log
Have node.js, homebrew and Ganache installed.
Any help would be greatly appreciated
you should create a seperate mint function outside of the constructor and call this after your contract is deployed
yeah this is an annoying error sometimes. to resolve it you should open your terminal as an administrator. i know how to do this on windows you can just right click and the option comes up to open your terminal as the administrator.
however from doing this quick google search a result came up saying that to use a terminal as an admin on mac you simply can
" To run commands with superuser privileges, use the sudo command . sudo stands for superuser do. You’re asked for the password of the current user. You’re asked to enter the password for adminUsername, after which a new shell is opened for that user."
let me know how you get on with this
Hi !!
I have the same problem right now, I don’t understand how I pass the requested params.
Thanks in advance.
is this for the advanced migrations lesson?
can u elaborate a little more onto which params and what context, like for a smart conract function or in the constructor or in migrations etc?
Hi, yes.
This is for the truffle multi-sig wallet assignment to practice using the terminal.
this is final code:
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;
}
}
this is the error message:
*** Deployment Failed ***
“Wallet” – Invalid number of parameters for “undefined”. Got 0 expected 2!.
Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.
Error: *** Deployment Failed ***
“Wallet” – Invalid number of parameters for “undefined”. Got 0 expected 2!.