2

trying to import to files from openzeppelin and chainlink in my contract file like so:

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

and i have a brownie-config.yaml file that looks like:

dependencies:
  - OpenZeppelin/openzeppelin-contracts@3.4.0
  - smartcontractkit/chainlink-brownie-contracts@1.0.2 
  compiler:
    solc:
      remappings: 
        - '@openzeppelin=OpenZepplin/openzeppelin-contracts@3.4.0'
        - '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.0.2'

when i run 'brownie compile' command i get:

CompilerError: solc returned the following errors:

contracts/AdvancedCollectible.sol:4:1: ParserError: Source "https:\github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol" not found: File outside of allowed directories.
import "https:\\github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol";
^------------------------------------------------------------------------------------------------------------------^

contracts/AdvancedCollectible.sol:6:1: ParserError: Source "https:\github.com/smartcontractkit/chainlink-brownie-contracts/blob/release-v1.0.2/contracts/src/v0.6/VRFConsumerBase.sol" not found: File outside of allowed directories.
import "https:\\github.com/smartcontractkit/chainlink-brownie-contracts/blob/release-v1.0.2/contracts/src/v0.6/VRFConsumerBase.sol";
^----------------------------------------------------------------------------------------------------------------------------------^

i also tried importing like below but no luck:

import "https:\\github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.4/contracts/token/ERC721/ERC721.sol";
import "https:\\github.com/smartcontractkit/chainlink-brownie-contracts/blob/release-v1.0.2/contracts/src/v0.6/VRFConsumerBase.sol";

4 Answers 4

3

So basically i accidentally created the brownie-yaml.config file outside of the project folder.

some-folder
 | -project-folder
 |  | -src
 |  | -contracts
 |  | -...
brownie-config.yaml

once I move the .yaml file into the project folder it all works fine

2
  • 1
    Could you please update the answer with what the solution was? This way anyone else will be able to follow along. Sep 12, 2021 at 20:06
  • Lovely, that's perfect! Sep 13, 2021 at 21:42
1

For me, I had accidentally not left a space after the - under the remappings. I had:

compiler:
  solc:
    remappings:
      -'@aave=aave/protocol-v2@1.0.1'
...

I needed:

compiler:
  solc:
    remappings:
      # notice the space
      - '@aave=aave/protocol-v2@1.0.1'
...
0

I placed correctly the yaml file and also did right and left spaces(see above answer) still got an error to both directories, "not found: File outside of allowed directories."

yaml file:

dependencies:
  - OpenZeppelin/openzeppelin-contracts@4.5.0
  - smartcontractkit/chainlink-brownie-contracts@0.4.0
compiler:
  solc:
    remappings:
      - '@openzeppelin = OpenZeppelin/openzeppelin-contracts@4.5.0'
      - '@chainlink=smartcontractkit/chainlink-browniecontracts@0.4.0'

importing lines:

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";
0

If you are using VSCODE. Create a folder .vscode in your root folder and then create a file settings.json inside .vscode with the following content. Ensure the path is correct -

{
"solidity.remappings":["@openzeppelin/=/Users/john/workspace/myproject/smart_contract/node_modules/@openzeppelin"] 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.