Receiving parse error while importing AggregatorV3Interface from chainlink repo #865
-
Receiving parse error while importing chainlink interface AggregatorV3Interface.sol
Brownie v1.17.2 - Python development framework for Ethereum
Compiling contracts...
Solc version: 0.8.8
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
ParserError: Source "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found: File not found.
--> contracts/Lottery.sol:5:1:
|
5 | import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Lottery.sol pragma solidity =0.8.8;
//Compiler using remote version: 'v0.8.8+commit.dddeac2f', solidity version: 0.8.8+commit.dddeac2f.Emscripten.clang
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; brownie-config.yaml file dependencies:
- smartcontractkit/[email protected]
complier:
solc:
remappings:
- '@chainlink=smartcontractkit/[email protected]' settings.json file for .vscode {
"solidity.compileUsingRemoteVersion": "v0.8.8+commit.dddeac2f",
"solidity.enableLocalNodeCompiler": false,
"solidity.defaultCompiler": "remote",
"solidity.remappings": [
"@chainlink/=/Users/xyz/.brownie/packages/smartcontractkit/[email protected]"
]
} Solidity compiler information
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hello @vibhaBlockchain Could your try deleting the .brownie folder and compiling again? |
Beta Was this translation helpful? Give feedback.
-
Alright so it's working now when creating a project again from scratch with limited functionalities first.
FundMe.sol// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract FundMe {
mapping(address => uint256) public addressToAmountFunded;
address[] public funders;
address public owner;
AggregatorV3Interface public priceFeed;
constructor(address _priceFeed) {
priceFeed = AggregatorV3Interface(_priceFeed);
owner = msg.sender;
}
function fund() public payable {
uint256 minimumUSD = 50 * 10**18;
require(
getConversionRate(msg.value) >= minimumUSD,
"You need to spend more ETH!"
);
addressToAmountFunded[msg.sender] += msg.value;
funders.push(msg.sender);
}
function getVersion() public view returns (uint256) {
return priceFeed.version();
}
function getPrice() public view returns (uint256) {
(, int256 answer, , , ) = priceFeed.latestRoundData();
return uint256(answer * 10000000000);
}
// 1000000000
function getConversionRate(uint256 ethAmount)
public
view
returns (uint256)
{
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;
return ethAmountInUsd;
}
function getEntranceFee() public view returns (uint256) {
// minimumUSD
uint256 minimumUSD = 50 * 10**18;
uint256 price = getPrice();
uint256 precision = 1 * 10**18;
return (minimumUSD * precision) / price;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function withdraw() public payable onlyOwner {
payable(msg.sender).transfer(address(this).balance);
for (
uint256 funderIndex = 0;
funderIndex < funders.length;
funderIndex++
) {
address funder = funders[funderIndex];
addressToAmountFunded[funder] = 0;
}
funders = new address[](0);
}
} brownie-config.yamldependencies:
# - <org>/<repo>@<version>
- smartcontractkit/[email protected]
compiler:
solc:
remappings:
# - '@name=<org>/<repo>@<version>''
- '@chainlink=smartcontractkit/[email protected]'
dotenv: .env
networks:
mainnet-fork-dev:
verify: False
default: development
wallets:
from-key: '0xabcabcabc' Checking the solidity compiler information
Since this compiled successfully. Matched the git repo version and solidity compiler version with a new project for this with limited Lottery.sol functionalities. This compiled successfully. Post that added a new Lottery2.sol with expanded functionalities per the original tutorial, it compiles now. Not able to pinpoint what was the issue though. Question: Before deleting the .brownie folder I checked the folder, I did have multiple version of the chainlink brownie project. Is the issue possibly related to that? |
Beta Was this translation helpful? Give feedback.
Alright so it's working now when creating a project again from scratch with limited functionalities first.
FundMe.sol
file and thebrownie-config.yaml
files from this project.FundMe.sol