How can I import AggregatorV3Interface

I'm trying to import AggregatorV3 but the file is nowhere to be found here is my code; I'm sorry in advance i'm still a beginner programmer.

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

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

contract Lottery {
    address payable[] public players; //to keep track of all players, payable array
    uint256 public usdEntryFee;
    AggregatorV3Intefrace internal ethUsdPriceFeed;

    constructor(address _priceFeedAddress) public {
        usdEntryFree = 50 * (10**18);
        ethUsdPriceFeed = AggregatorV3Interface(_priceFeedAddress); //we need to pass the address of aggv3 in constructor
    }

    function enter() public payable {
        //payable since we want them to pay in eth
        //50 $ minimum
        players.push(msg.sender);
    }

    function getEntranceFee() public view returns (uint256) {}

    function startLottery() public {}

    function endLottery() public {}
}

here is my Yaml file:

dependencies:
  - smartcontractkit/[email protected]

compiler:
  solc:
    remappings:
    - '@chainlink=smartcontractkit/[email protected]'

here is the error:

(base) marc@Marcs-MacBook-Pro smartcontract-lottery % brownie compile
Brownie v1.17.2 - Python development framework for Ethereum

Compiling contracts...
  Solc version: 0.8.11
  Optimizer: Enabled  Runs: 200
  EVM Version: Istanbul
CompilerError: solc returned the following errors:

ParserError: Source "/Users/marc/.brownie/packages/smartcontractkit/[email protected]/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found: File not found.
 --> contracts/Lottery.sol:4:1:
  |
4 | import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I tried changing compiler: solc: remappings: - '@chainlink=smartcontractkit/[email protected]' to @0.2.1 I also tried changing solidity version to a newer version and it's not working Thanks in advance!


Solution 1:

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

and in the yaml file doing:

Solution 2:

I solved it by replacing import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; with import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; My mistake, cheers!