Cannot find smart contracts from NPM modules (e.g. @openzeppelin/contracts) when truffle-plugin-verify is installed globally
See original GitHub issueHello, 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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:40 (11 by maintainers)
Top Results From Across the Web
@openzeppelin/contracts - npm
A library for secure smart contract development. Build on a solid foundation of community-vetted code. Implementations of standards like ...
Read more >1 - Stack Overflow
After a research in the chainlink-docs, I find a solution. ... npm install -g @chainlink/contracts truffle-plugin-verify. and then
Read more >go ethereum - Installation of openzeppelin/contracts Library
However, I am not finding any example on how to configure the truffle-config.js file so that the node_modules folder can be properly found....
Read more >How to Create and Deploy a Factory ERC-1155 Contract on ...
1. With the increasing popularity of NFTs, Polygon, a fast-growing blockchain, has become the go-to choi... 2. The ERC-1155 standard was proposed back...
Read more >How to verify with Hardhat or Truffle a smart contract using ...
Install the plugin. npm install --save-dev @nomiclabs/hardhat-etherscan ... Truffle cannot flatten openzeppelin/contracts.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Well, I just followed @script-money 's suggestion and copied all the files into the contracts directory
I wonder if there’s a way that we don’t have to do that and verify will recognize files that live in node_modules?
I ran into this issue as well,
truffle compileworked ok, andmigrateworked as well. But when I triedtestthe openzeppelin artifact files couldn’t be found by the resolver.I noticed the openzeppelin contracts were not listed in the compilation logs for
testThen I did
truffle test --compile-alland that fixed it. Subsequent runs oftruffle testwithout the--compile-allflag work as well now.Dropping this here in hopes this helps someone get past this quicker than I did.