truffle-plugin-verify
truffle-plugin-verify copied to clipboard
Cannot find module '@openzeppelin/contracts/GSN/Context.sol'
Hello, whenever i try to verify my ERC721 Contract I get the error message: "Cannot find module '@openzeppelin/contracts/GSN/Context.sol'".
I am using the openzeppelin library (installed via npm install).
My SmartContract starts like this:
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/ownership/Ownable.sol";
contract ChallengeManager is LockFactory, ERC721, Ownable {
...
The ERC721 Contract has a dependency to the requested "Context.sol" Contract.
I also tried to import "@openzeppelin/contracts/GSN/Context.sol" on my ChallengeManager Contract, but i still get the same Error.
I think Ownable is under import "@openzeppelin/contracts/access/Ownable.sol";.
Thanks for the reply. The issue is definitely coming from the ERC721 import. I already removed the Ownable part and still got the same fault. But I can verify it if i remove the ERC721 import.
By the way, I forgot to mention that im using version "2.5.1" of the openzeppelin library. Maybe this explains the difference in the import. I have to use this version, because I am using another library which is wirtten in solidity version 5.17.
Do you have your code repository available somewhere to check out what might be the issue? Also what OS are you using?
Yes, thats the contract I'm trying to verify: https://github.com/sudojanuc/fitness-challenge/blob/main/contracts/ChallengeManager.sol
Contract address (rinkeby): 0x4D70519d63158e7be67c1B9B01C4b126039805FB
I am using Windows 10, but i also failed on Linux.
I might have run into a similar issue. "Cannot find module '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'" I am using @openzeppelin/[email protected]
Did anyone sort this issue out I seem to be running into a very similar issue "Cannot find module '@openzeppelin/"
Would love some help with this one.
my process is:
-
mkdir newContact
-
cd newContact
-
npm init -y
-
truffle init
-
npm install @openzeppelin/contracts
-
npm install truffle-plugin-verify
-
yarn add -d truffle-plugin-verify (this gives a small error)
-
warning ../../../package.json: No license field error Missing list of packages to add to your project.
-
Add all necessary code (.js and .sol)
-
truffle compile (code compiles fine)
-
truffle migrate --network rinkeby (code deploys fine)
-
truffle run verify NewTest --network rinkeby --debug (code below)
Truffle debug output:
DEBUG logging is turned ON
Running truffle-plugin-verify v0.5.15
Verifying NewTest
Reading artifact file at /Users/***/Documents/tst/newTest/build/contracts/NewTest.json
Retrieving constructor parameters from https://api-rinkeby.etherscan.io/api?apiKey=FCCUFVZVZCN462K616Q6WCVJI4FNRMMTEX&module=account&action=txlist&address=0x5a1a3b04e98Cb8845cc4ADe0274FA7A991F6000f&page=1&sort=asc&offset=1
Constructor parameters retrieved: 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000e7777772e6675636b79612e636f6d000000000000000000000000000000000000
Cannot find module '@openzeppelin/contracts/utils/introspection/IERC165.sol'
Require stack:
- /usr/local/lib/node_modules/truffle-plugin-verify/verify.js
- /usr/local/lib/node_modules/truffle/node_modules/original-require/index.js
- /usr/local/lib/node_modules/truffle/build/cli.bundled.js
Failed to verify 1 contract(s): NewTest
package.json:
"name": "newTest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@openzeppelin/contracts": "^4.3.2",
"@openzeppelin/test-helpers": "^0.5.13",
"truffle-plugin-verify": "^0.5.3"
}
}
truffle-config.js:
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
},
rinkeby: {
host: "localhost", // Connect to geth on the specified
port: 8545,
from: "***", // default address to use for any transaction Truffle makes during migrations
network_id: 4,
gas: 5000000 // Gas limit used for deploys
}
},
compilers: {
solc: {
version: "0.8.0", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
// settings: { // See the solidity docs for advice about optimization and evmVersion
// optimizer: {
// enabled: false,
// runs: 200
// },
// evmVersion: "byzantium"
// }
}
},
plugins: [
'truffle-plugin-verify'
],
api_keys: {
etherscan: "***"
}
};
Same issue here - https://github.com/rkalis/truffle-plugin-verify/issues/117
Not resolved yet
To anyone experiencing this issue: what version of Node are you running?
same issue, I can not verify the contracts where I used the openzeppelin library (Context.sol)
I'm using v14.17.5 (node.)
Any reproduction repos?
sure. https://github.com/romuloags/redCriptoPay/tree/testnet I deployed my contracts on ropsten , I have only been able to verify 1 contract (the one doesn't have openzeppelin library)
Thanks for providing the repo. When I ran npm install and tried to verify I got some other error messages which were resolved after upgrading the plugin from 0.5.3 to 0.5.20.
From there I have tried to reproduce this issue with a lot of different configurations (any combination of using Node 12/14 and NPM 6/7/8/Yarn), but I wasn't able to reproduce it.
@romuloags what OS and Truffle version are you running? And is there anything else that you can think of that might be relevant?
I'm using WSL2 Ubuntu 20.04.2 LTS (GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64) npm: '6.14.14', Truffle v5.4.7 (core: 5.4.7) Solidity v0.5.16 (solc-js) Node v14.17.5 Web3.js v1.5.2
Could you just try updating to the latest Truffle (npm install -g truffle@latest) and retry the process? That's the only thing that I can think of atm.
It did not work.
I decided to copy and paste OpenZeppelin libraries directly in the contracts, and it worked just fine. even though you have to do this and can be kind of annoying, this plugin really helps to verify the contracts faster and easier than directly from etherscan. thanks for the help though.
I have the same issue but with a package that is local (bootstrapped with lerna) instead of OpenZeppelin.
npm: 7.17.0 node: 14.15.1 truffle: 5.4.26 truffle-plugin-verify: 0.5.20 solidity: 0.8.6
Been dealing with the same issue, seems like you have to have the truffle-config.js and package.json in the same directory, for example, mine is within the src directory for my project. This is bad practice but works with no errors. Also, truffle-plugin-verify does not work for the rinkeby test net from what I can tell.
@nicknovoa03 do you have a repo with the config where it doesn't work for you that I can look at?
cp -r node_modules/@openzeppelin contracts then run verify works for me
That's interesting @script-money, do you have a repo where I can reproduce this issue?
That's interesting @script-money, do you have a repo where I can reproduce this issue?
https://github.com/script-money/blockchain-developer-bootcamp-final-project
I can't reproduce the issue on that repository. People with this issue, please provide your OS, Truffle version, Node version, and NPM/Yarn version in the comments to figure out common things between the people with these issues.
cp -r node_modules/@openzeppelin contractsthen run verify works for me
macOS big Sur 11.6 Truffle v5.4.15 (core: 5.4.15) Node v14.17.6 yarn version v1.22.10 truffle-plugin-verify v0.5.20
😅 so it looks like we have people experiencing this issue with Windows/Mac/Linux, both with Yarn and NPM, so it doesn't look like there's anything you guys have in common . But at the same time the majority of people (including myself) don't have this issue. I'm stumped.
It has been deprecated in the latest version. https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2520
I ran into this issue as well, truffle compile worked ok, and migrate worked as well. But when I tried test the openzeppelin artifact files couldn't be found by the resolver.
I noticed the openzeppelin contracts were not listed in the compilation logs for test
Then I did truffle test --compile-all and that fixed it. Subsequent runs of truffle test without the --compile-all flag work as well now.
Dropping this here in hopes this helps someone get past this quicker than I did.
This issue happens when you want to use an older version of SDKs with a newer version and mixing all. To prevent this to happen, try using the same version or updating SDK versions from node_modules. This always works and it's better to use the latest version :)