question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find smart contracts from NPM modules (e.g. @openzeppelin/contracts) when truffle-plugin-verify is installed globally

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:40 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
emilyJLin95commented, Sep 7, 2022

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?

1reaction
dherbstcommented, Apr 19, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found