brownie-config remappings error when trying to import from chainlink

Viewed 604

I am trying to import this code

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";

but "Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File import callback not supported" error messages appear when i try to compile.

My brownie-config.yaml file has

dependencies:
  # - <organization/repo>@<version>
  - smartcontractkit/chainlink-brownie-contracts@1.1.1
compiler:
  solc:
    remappings:
      - '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1'

but the code still results in the same error. Are there any fixes to this?

2 Answers

It appears that running brownie compile failed to install the dependencies specified in brownie-yaml.config. You can check brownie installed package with:

$ brownie pm list

If the package is missing, you need to install the package first:

$ brownie pm install smartcontractkit/chainlink-brownie-contracts@1.1.1  

Then, compile the project again: (the -a flag is optional, it is to force recompile all contracts)

$ brownie compile -a

The error should be gone, since now we correctly install the dependency first before compiling the contracts

I solved it by doing: npm install @chainlink/contracts --save

and in the yaml file doing:enter image description here

Related