0

Hello I was starting to write some solidity code with brownie as eth-environment, I tried to compile the code and the import statement is showing en error -

ParserError: Source "@smartcontractkit/chainlink-brownie-contracts/contracts/src/v0.8/VRFConsumerBase.sol" not found: File not found. Searched the following locations: "".

Actually I have 2 import statements and both of them was showing error, I sorted the first one out by adding current release version from github, but this one is not sorted and it keeps showing error, here is my solidity imports -

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@smartcontractkit/chainlink-brownie-contracts/contracts/src/v0.8/VRFConsumerBase.sol";

I edited the brownie-config.yaml file -

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

Any help with some explanation would be of great help, Thanks.

2 Answers 2

1

I believe in your smart contract you need to have the standard import pathing: ie:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

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

You may have to download the contracts before deploying, but compiling should download them I believe.

npm install @chainlink/contracts --save
0

First, install the chainlink-brownie-contracts package by

brownie pm install smartcontractkit/[email protected]

That still hadn't worked for me. I then needed to follow the directory in which brownie installed the package. In my case it was

/Users/<your username>/.brownie/packages/smartcontractkit/[email protected]/contracts/src/

There, I didn't find the v0.8 folder but v0.7. So in the FundMe.sol file I just changed the import directory to

import "@chainlink/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol"; //importing Chainlink interface

Then everything worked.

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.