3

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/[email protected]
  - smartcontractkit/[email protected] 
  compiler:
    solc:
      remappings: 
        - '@openzeppelin=OpenZepplin/[email protected]'
        - '@chainlink=smartcontractkit/[email protected]'

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";

5 Answers 5

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. Commented Sep 12, 2021 at 20:06
  • Lovely, that's perfect! Commented 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/[email protected]'
...

I needed:

compiler:
  solc:
    remappings:
      # notice the space
      - '@aave=aave/[email protected]'
...
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/[email protected]
  - smartcontractkit/[email protected]
compiler:
  solc:
    remappings:
      - '@openzeppelin = OpenZeppelin/[email protected]'
      - '@chainlink=smartcontractkit/[email protected]'

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"] 
}
0

For me i named the file brownie-sonfig.yaml instead of brownie-config.yaml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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