Search code examples
ethereumsoliditybrownie

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!


Solution

  • 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