Lottery.sol file
"
CompilerError: solc returned the following errors:
"contracts/Lottery.sol:4: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/Lottery.sol:5:1: ParserError: Source "@openzeppelin/contracts/access/Ownable.sol" not found: File outside of allowed directories. import "@openzeppelin/contracts/access/Ownable.sol"; ^--------------------------------------------------^"
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Lottery is Ownable {
address payable[] public players;
uint256 public usdEntryFee;
AggregatorV3Interface internal ethUsdPriceFeed;
enum LOTTERY_STATE {
OPEN,
CLOSED,
CALCULATING_WINNER
}
LOTTERY_STATE public lottery_state;
// OPEN = 0
//CLOSED = 1
//CALCULATING_WINNER = 2
LOTTERY_STATE public lottery_state;
constructor(address _priceFeedAddress) public {
usdEntryFee = 50 * (10**18);
ethUsdPriceFeed = AggregatorV3Interface(_priceFeedAddress);
lottery_state = LOTTERY_STATE.CLOSED; // or "lottery_state = 1;
}
function enter() public {
// $50 minimum
require(lottery_state == LOTTERY_STATE.OPEN); // or lottery_state == 0;
require(msg.sender >= getEntranceFee(), "Not enough ETH!");
players.push(msg.sender);
}
function getEntranceFee() public view returns (uint256) {
(, int256 price, , , ) = ethUsdPriceFeed.latestRoundData();
uint256 adjustedPrice = uint256(price) * 10**10; //18 decimals
//50, 2000 / ETH
// 50/2,000
//50 * 100000 / 2000
uint256 costToEnter = (usdEntryFee * 10**18) / adjustedPrice;
return costToEnter;
}
function startLottery() public onlyOwner {
require(
lottery_state == LOTTERY_STATE.CLOSED,
"Can't start a new lottery yet!"
);
lottery_state = LOTTERY_STATE.OPEN;
}
function endLottery() public {
//require(lottery_state == 50.000, "The winner is 50.000");
//lottery_state = LOTTERY_STATE.CALCULATING_WINNER;
}
}
brownie-config.yaml file
dependecies:
- smartcontractgit/[email protected]
- OpenZeppelin/[email protected] // the error is probably here
compile:
solc:
remappings:
- '@chainlink=smartcontractkit/[email protected]'
- '@openzeppelin=OpenZeppelin/[email protected]' // The error can be here
networks:
mainnet-fork:
eth_usd_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'