0

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:

  1. Reinstalling Dependencies: I removed node_modules and yarn.lock and then ran yarn install again.
  2. Check Path: I verified the import path to ensure it is correct.
  3. Check Hardhat Version: I confirmed that Hardhat is up to date.
  4. 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!

2
  • What's the version of @chainlink/contracts in your package.json file? Commented Jul 27 at 16:45
  • a Version is @chainlink/contracts": "^1.2.0" Commented Jul 28 at 15:23

1 Answer 1

1

In the latest version of @chainlink/contracts (i.e, v1.2.0 at this point in time), the AggregatorV3Interface.sol file has been moved to the shared/interfaces folder.

Therefore, the correct import statement should be:

import "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";

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.