我正在尝试编译下面的代码,但无法正确编译。似乎有编译错误,但我不明白我做错了什么?我以为是编译指示版本或 brownie config.yaml 但问题似乎与它们无关。
有人可以帮我弄这个吗?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
//definition of the contract lottery: the contract is based on the 4 functions below
contract Lottery {
address payable[] public players;
uint256 public usdEntryFee;
AggregatorV3Interface internal ethUsdPriceFeed;
enum LOTTERY_STATE {
OPEN,
CLOSE,
WINNER
}
LOTTERY_STATE public lottery_state;
// 0
// 1
// 2
constructor(address _priceFeedAddress) public {
usdEntryFee = 50 * (10**18);
ethUsdPriceFeed = AggregatorV3Interface(_priceFeedAddress); //converting the optimal price feed
}
function enter() public payable {
//in order to pay player we need that the funciont enter is "payable" and also wee need to track the players who join to the lottery
// $50 minimum enter
require(lottery_state == LOTTERY_STATE);
require(msg.value >= getEntranceFee(), "Not enough ETH!");
players.push(msg.sender);
}
function getEntranceFee() public view returns (uint256) {
(, int256 price, , , ) = ethUsdPriceFeed.lastestRoundData();
uint256 adjustedPrice = uint256(price) * 10**10; //18 decimals
// $50, $2,000 / ETH
// 50/2,000
// 50 * 100000/2000
uint256 costToEnter = (usdEntryFee * 10**18) / adjustedPrice;
return costToEnter;
}
function startLottery() public onlyOwner {
require(
lottery_state == LOTTERY_STATE.CLOSE,
"Lottery is closed, You can't start a new lottery!"
);
lottery_state = LOTTERY_STATE.OPEN;
}
//function that determinate the winner of Lottery with a pseudonumber
function endLottery() public onlyOwner {
uint256(
keccack256(
abi.encodePacked(
nonce,
msg.sender,
block.difficulty, //can actually be manipulated by miners >> solution Chainlink VRF
block.timestamp
)
)
) % players.lenght;
}
}
这里有终端的输出:
Compiling contracts...
Solc version: 0.8.10
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> contracts/lottery.sol:12:5:
|
12 | constructor(address _priceFeedAddress) public {
| ^ (Relevant source part starts here and spans across multiple lines).
TypeError: Member "push" not found or not visible after argument-dependent lookup in address payable[] storage ref.
--> contracts/lottery.sol:20:9:
|
20 | players.push(msg.sender);
| ^^^^^^^^^^^^
(base) PS C:\Users\ssida\Desktop\demos\smartcontract-lottery>
布朗尼配置在这里:
dependencies:
- smartcontractkit/chainlink-brownie-contracts@0.2.1
compiler:
solc:
remappings:
- "@chainlink=smartcontractkit/chainlink-brownie-contracts@0.2.1"
有什么帮助吗?