Hi @inzhagey
Please push your code to github and share the repo.
Is this anything to worry about? I was still able to run truffle but I saw that on Filipās demonstration he did not have anything that resembled these messages.
Hi @DJaySplash
The warnings you get are related to deprecated dependencies that truffle is using for its installation. All good no need to do anything.
Cheers,
Dani
Hi @inzhagey
Please upload the whole truffle project not just the files.
Also donāt change your file names (truffleconfig should be truffle-config).
I need to have the exact same repo you have in your machine as the issue is somewhere in your code and we need to be able to replicate it.
Hi @inzhagey
I cloned your repo and I was able to migrate it correctly.
Run truffle -v
and write here the version of Truffle installed.
Also try to update truffle npm i truffle
.
truffle develop
;truffle migrate --reset
;The configuration is correct so it has to be something in your machine.
Make sure you are compiling the right project (from your terminal you have to be inside the root folder of your project āTokenProjectā).
If you keep getting the same error, other than you truffle version please cd
into the root folder of your project, then run ls
and screenshot the results.
Then run cd contracts
, ls
and send me the screenshot.
Let me know,
Dani
It says Truffle v5.3.0 and it worked, I think it was an update issue. Thank you for your help
Even though it was previously running and working, thereās still a red line on the pragma solidity version
and i think it may be interfering with the compile
You might have typed wrong imports
instead of import
, apparently is not in the contract, so you can check in your migration or test files. Some where, you type it incorrectly.
Carlos Z
I cant find imports anywhere
I saw that I misspelled ERC20.sol and the /ā¦/ā¦/utils/Context.sol after import, but I fixed both of them too and I exited and started truffle develop again and got the same error. What do you mean by test files?
Could you please upload it to your github repo? Your contract looks ok, have you modify any of the openzeppelin contract? Those should never be modified.
Anyway I want to try to replicate the error myself, maybe I could find something that is not showed in your screenshots
Carlos Z
Hi All,
A question about the difference between calls and transactions.
I got confused because the Remix IDE shows functions returned values under ādecoded outputā even in the case of a transaction invocation.
Thanks!
Matt
So the only error that i found was on the minting function that is beign called from ther ERC20Capped contract instead the ERC20.
So i just change your token contract a little bit and its compile great for me:
pragma solidity >=0.6.0 < 0.8.3;
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";
contract MyToken is ERC20Capped {
constructor () ERC20("Penny", "PNY" ) ERC20Capped(100000){
ERC20._mint(msg.sender, 1000);
}
}
Carlos Z
TypeError: Cannot read property āimportsā of undefined
at Object. (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/requiredSources.js:98:1)
at Generator.next ()
at fulfilled (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-common/dist/src/profiler/requiredSources.js:5:42)
and these errors
I noticed that Filips ERC20Capped.sol file had
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), "ERC20Pausable: token transfer while paused");
}
which is not my ERC20Capped.sol:
/
/ SPDX-License-Identifier: MIT
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 immutable private _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);
}
}
, but itās in my ERC20Pausable.sol contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../security/Pausable.sol";
/**
* @dev ERC20 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*/
abstract contract ERC20Pausable is ERC20, Pausable {
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
require(!paused(), "ERC20Pausable: token transfer while paused");
}
}
So I tried to write
contract MyToken is ERC20Pausable {
constructor () ERC20("Penny", "PNY" ) ERC20Capped(100000){
ERC20._mint(msg.sender, 1000);
}
}
and im still getting that error. I updated my github btw.
Hi @inzhagey
Follow the steps below and let me know:
node_modules
folder completely.npm i @openzeppelin/contracts
truffle migrate --reset
If that did not fix:
node -v
and truffle -v
and write here the versions of bothCheers,
Dani
Um, I got a bunch of warnings
node -v and truffle -v: v14.15.4