2

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/chainlink-brownie-contracts@1.1.1

compiler:
  solc:
    remappings:
    - '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1'

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/chainlink-brownie-contracts@1.1.1/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/chainlink-brownie-contracts@1.1.1' to @0.2.1 I also tried changing solidity version to a newer version and it's not working Thanks in advance!

  • when i try to manually install using: brownie pm install smartcontractkit/chainlink-brownie-contracts@1.1.1 it says file already exists – getrektnoop Jan 12 '22 at 14:32

4 Answers4

3

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

and in the yaml file doing:

1

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!

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 12 '22 at 16:15
0
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";

use v0.6 instead of v0.8

ouflak
  • 2,458
  • 10
  • 44
  • 49
0

Hi I was also stuck in a similar problem. Make sure that the brownie-config.yaml file is not inside the test folder and is kept seperately. Hope this helps. check the below image to see how I saved my brownie-config.yaml file