Brownie Chainlink Import Error in VSCode – ‘File Import Callback Not Supported’ Solution

browniechainlinkpythonsolidity

enter image description here

The code seems to have successfully compiled, but VSCode keeps showing this error –

"@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found. File import callback not supported"

Best Answer

So, I figured out a solution.

Step 1 - brownie pm install [ORGANIZATION]/[REPOSITORY]@[VERSION]. Do this in your terminal. In my case, it'll be

brownie pm install smartcontractkit/chainlink-brownie-contracts@0.2.2
brownie pm install OpenZeppelin/openzeppelin-contracts@4.4.0

Step 2 - Add these in your VSCode settings,

  "solidity.remappings": [
    "@chainlink/=/Users/<USERNAME>/.brownie/packages/smartcontractkit/chainlink-brownie-contracts@0.2.2",
    "@openzeppelin/=/Users/<USERNAME>/.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.4.0"
  ]

All the versions are the latest as of 12-Dec-2021

Lastly to check all of your installed packages just type brownie pm list in your terminal. In my case, it looks something like this.

enter image description here

VOILA!

Related Topic