Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi guys.
At around hours 5:10 I encountered this error.
CompilerError: solc returned the following errors:

contracts/FundMe.sol:5:1: ParserError: Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File outside of allowed directories.
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";

Capture

my brownie.config.yamal

Capture

You must be logged in to vote

It's not brownie_config.yaml is brownie-config.yaml with - so that's why your brownie can't find the configuration, give it a try ;)
Best regards.

Replies: 9 comments · 19 replies

Comment options

This is the FundMe.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.6.6;

import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";

contract FundMe {
    using SafeMathChainlink for uint256;
    
    mapping(address => uint256) public addressToAmountFunded;
    address[] public funders;
    address public owner;
    
    constructor() public {
        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){
        AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
        return priceFeed.version();
    }
    
    function getPrice() public view returns(uint256){
        AggregatorV3Interface priceFeed = AggregatorV3Interface(0x8A753747A1Fa494EC906cE90E9f37563A8AF630e);
        (,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;
    }
    
    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }
    
    function withdraw() payable onlyOwner public {
        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);
    }
}

this the brownie-config.yaml:

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

dotenv: .env

wallets:
  from_key: ${PRIVATE_KEY}

And this is the error:

Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS E:\Web development\My projects\Blockchain projects\brownie_fund_me> brownie compile
INFO: Could not find files for the given pattern(s).
Brownie v1.17.0 - Python development framework for Ethereum

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

contracts/FundMe.sol:5:1: ParserError: Source "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol" not found: File outside of allowed directories.
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
^--------------------------------------------------------------------------^

contracts/FundMe.sol:6:1: ParserError: Source "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol" not found: File outside of allowed directories.
import "@chainlink/contracts/src/v0.6/vendor/SafeMathChainlink.sol";
^------------------------------------------------------------------^

PS E:\Web development\My projects\Blockchain projects\brownie_fund_me>
You must be logged in to vote
2 replies
@PatrickAlphaC
Comment options

really odd. Everything looks right. This error means it can't find that folder.

what version of python are you using?

@ace-brown
Comment options

Yeah that's really odd. I've got installed python version 2.7, 3.9 and 3.10 on my 64 win10. But on the system environment, I set all my paths to python 3.9.

Comment options

It's not brownie_config.yaml is brownie-config.yaml with - so that's why your brownie can't find the configuration, give it a try ;)
Best regards.

image

You must be logged in to vote
3 replies
@ace-brown
Comment options

That's it. It was the underscore keeping me form going on for 2 days. lol. BTW, thank you so much man.

@cromewar
Comment options

You are welcome, I'm glad it helped.

@pgraciae
Comment options

Had the same problem here! Thanks!

Answer selected by ace-brown
Comment options

I have the same issue. I spelled the "brownie-config.yaml" folder correctly. However, the error still occurs.
My files have the same content as the ones posted here. The only difference is that I use a virtual environment, so my folder structure is a little bit different:
image

The "dev" folder contains the contracts, scripts etc. and the "virtualenv" folder contains everything that belongs to the virtual environment.
Can someone help?

You must be logged in to vote
4 replies
@s1n7
Comment options

additional information: my solidity version seems to be the problem:
image

@cromewar
Comment options

just right, change the global compiler version - remote and set it the version you need. If you have compiler error also attach them here please.

@s1n7
Comment options

you mean right clicking on that and then select "Solidity: Change global compiler version (remote)"? And which version should I select?
I'm sorry, I do not fully understand how to use the versions yet...

@cromewar
Comment options

There are some thing to take in consideration here, the extension provided by Juan Blanco is by far the best for Solidity development, however it has its faults, for example let's suppose you are going to work with a project using solidity version 0.8.0, so you should change the compiler version to it and it should work, but, what if you import another file which uses an anterior version? for example a Mock, and the mock has something like this:

pragma solidity ^0.6.0;

Event tough the compiler will work just fine, because you have the ^ symbol (meaning that you could use that version of the compiler or any another one higher) the VScode Extension is going to complain about the version you are using are not the same as in the file.

My recommendation, just use the compiler version according to your main contract file, ^0.6.6 or 0.8.0 in most cases (that I've seen) and for test contracts don't pay attention to vscode complaining to them (as long as your main compiler is higher to the required version).

Remember changing between version is as simple as right click and select the option.

image

Comment options

Perhaps it's a grammar mistake in brownie-config.yaml , i wrongly type the word commpiler and that's the case

You must be logged in to vote
1 reply
@cromewar
Comment options

Nice hint @steven2077

Comment options

I got the same problem, and can't find the reason no one of the listed above

You must be logged in to vote
0 replies
Comment options

Hi - I have the same issue and the solutions above have not worked.

Fundme.

Below is the brownie-config.yaml file:

yaml

I also added this to settings.json file
"solidity.remappings": [
"@chainlink/=/Users/Tim/.brownie/packages/smartcontractkit/chainlink-brownie-contracts@1.1.1",
"@openzeppelin/=/Users/Tim/.brownie/packages/OpenZeppelin/openzeppelin-contracts@4.4.0"

You must be logged in to vote
3 replies
@cromewar
Comment options

@tredw it seems your brownie-config.yaml is inside your test folder, is it?
if that's true, it must be on the project root directory.

@tredw
Comment options

Thanks! You're right much appreciated. Lesson I've learnt from this is sometimes when stuck just need to re-watch video from the beginning of lesson you're on and go through the coding process again to hopefully catch what you missed the first time.

@Yadu-blockchain
Comment options

Thank you so much man! I was working with this problem for a very long time. Finally.

Comment options

Hi! I am a complete noob at this but learning quickly. It seems I got suck here and can't figure out what is the problem. Any help pls??

image

here is my brownie-config.yaml

image

You must be logged in to vote
4 replies
@cromewar
Comment options

Hello @andrewvella1991 I don't see the mockContract on your contracts folder, you must create a folder called tests and put there the MockContract.

@tolivern
Comment options

Maybe it is because you wrote "dependecies" instead of "dependencies"...? (I am noob as well)

@cromewar
Comment options

yes you are right @tolivern 100% missed it

@Madhur-Prakash
Comment options

thnx @tolivern, you are indeed correct

Comment options

Hello Please can some help me with this issue, i got the some issue of you guys but i don't know where is the problem

This is the contract:
Screenshot 2022-03-24 at 19 43 34
Screenshot 2022-03-24 at 23 25 08
Screenshot 2022-03-24 at 19 47 11
Screenshot 2022-03-24 at 19 47 23
Screenshot 2022-03-24 at 20 03 01

You must be logged in to vote
2 replies
@rohit9888
Comment options

it is remappings not remapping. add 's'

@harshpreetwmk
Comment options

thanks brother love you

Comment options

Screenshot 2022-04-30 at 4 18 02 PM

I had the same error, apparently, I didn't leave a space between the - and '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1' in my remappings.

Solved it by adding the space
Screenshot 2022-04-30 at 4 18 58 PM

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
Morty Proxy This is a proxified and sanitized view of the page, visit original site.