I'm working on a Hardhat project and I’m encountering an issue with importing a contract interface from Chainlink. Here is the relevant portion of my Solidity code:
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
When I try to compile the contract using Hardhat, I get the following error message:
Source "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found: File import callback not supported
I've followed the steps to install Chainlink dependencies using Yarn:
yarn add @chainlink/contracts
And my Hardhat configuration (hardhat.config.js
) is as follows:
require('@nomiclabs/hardhat-ethers');
require('@nomiclabs/hardhat-etherscan');
require('hardhat-deploy');
require('hardhat-gas-reporter');
require('solidity-coverage');
module.exports = {
solidity: "0.8.0",
networks: {
// Network configuration
},
etherscan: {
apiKey: "YOUR_ETHERSCAN_API_KEY"
}
};
I have also ensured that @chainlink/contracts
is listed in my node_modules
directory and package.json
.
I've tried the following solutions but they haven't resolved the issue:
- Reinstalling Dependencies: I removed
node_modules
andyarn.lock
and then ranyarn install
again. - Check Path: I verified the import path to ensure it is correct.
- Check Hardhat Version: I confirmed that Hardhat is up to date.
- Add Chainlink as a Dependency: Double-checked that Chainlink is properly added to the project.
Despite these steps, the error persists.
Has anyone encountered this issue before or can provide any insights into how to resolve this? Any help would be greatly appreciated!
@chainlink/contracts
in yourpackage.json
file?@chainlink/contracts": "^1.2.0"