Guled
Guled

Reputation: 47

Trying to compile contract but getting "ParserError: Source "@openzeppelin/contracts/token/ERC1155/IERC1155.sol" not found: File not found."

I am trying to compile a contract so that I can start the brownie console but I keep getting the error for the contracts I am trying to import.

ParserError: Source "@openzeppelin/contracts/token/ERC1155/IERC1155.sol" not found: File not found.
 
--> contracts/DutchAuction.sol:3:1:

  |
3 | import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^`

How would I go about fixing this? Much appreciated!

Upvotes: 1

Views: 1708

Answers (2)

maskara
maskara

Reputation: 359

I struggled with the same issue for days. I realized my mistake: the config file was named brownie_config.yaml (with underscore) instead of brownie-config.yaml (with dash)

Upvotes: 0

Patrick Collins
Patrick Collins

Reputation: 6131

When importing packages, per the brownie docs you first have to install the packages. You can install them from:

One of the most common ways is just installing directly from github releases. To do this, you have to update your brownie-config.yaml (or make this file it if you haven't already)

You then have to add the github repo as a dependency with the structure:

REPO_OWNER/REPO_NAME@RELEASE_VERSION

And then add it to remappings if you want to use the @ syntax, like so:

dependencies:
  - OpenZeppelin/[email protected]
compiler:
  solc:
    remappings:
      - '@openzeppelin=OpenZeppelin/[email protected]'

This example should work for this specific use case if you pop it into your brownie-config.yaml

Upvotes: 3

Related Questions