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"
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityThe 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"
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/[email protected]
brownie pm install OpenZeppelin/[email protected]
Step 2 - Add these in your VSCode settings,
"solidity.remappings": [
"@chainlink/=/Users/<USERNAME>/.brownie/packages/smartcontractkit/[email protected]",
"@openzeppelin/=/Users/<USERNAME>/.brownie/packages/OpenZeppelin/[email protected]"
]
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.
VOILA!
I did a brownie pm install for both the packages and also added following in the settings.json for Solidity
{
"workbench.colorTheme": "Default Dark+",
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"solidity.compileUsingRemoteVersion": "0.6.0",
"editor.minimap.enabled": false,
"editor.bracketPairColorization.enabled": true,
"solidity.remappings": [
"@chainlink/=/Users/<USERNAME>/.brownie/packages/smartcontractkit/[email protected]",
"@openzeppelin/=/Users/<USERNAME>/.brownie/packages/OpenZeppelin/[email protected]"
]
}
After doing this the brownie pm list shows the following: Brownie v1.16.4 - Python development framework for Ethereum
The following packages are currently installed:
smartcontractkit
├─smartcontractkit/chainlink-[email protected]
└─smartcontractkit/[email protected]
OpenZeppelin
└─OpenZeppelin/[email protected]
And the same problem persists: Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File import callback not supported
I am using macOS.
In my case, what fixed it for me was install another version of solidity. Source: https://www.youtube.com/watch?v=5qTdQNCMwk8
I was operating on v0.0.137 The guy says to install version 0.0.135 and that fixed everything for me.
Best of luck.
for Brownie 1.19.3 in vs code, you'll need to do the followings:
considering we have:
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@erc721a/contracts/ERC721A.sol";
add the following section to your project's brownie-config.yaml file
dependencies:
- OpenZeppelin/[email protected]
- chiru-labs/[email protected]
compiler:
solc:
remappings:
- '@openzeppelin=OpenZeppelin/openzeppelin-co[email protected]'
- '@erc721a=chiru-labs/[email protected]'
the chiru-labs/[email protected]
for example, is achieved by combining the repository name + @ + release version :
also don't forget to create an access token on GitHub and set it as an environment variable like: GITHUB_TOKEN=ghp_2m7rVBTx9c88GZS...
then you'll need to run this command in terminal brownie compile
brownie will automatically download those two packages and the errors will go away.
you can check to see if the packages are downloaded using brownie pm list
command.