-
|
i get this error in the line 106: Code: // Layout of Contract:
// license
// version
// imports
// errors
// interfaces, libraries, contracts
// Type declarations
// State variables
// Events
// Modifiers
// Functions
// Layout of Functions:
// constructor
// receive function (if exists)
// fallback function (if exists)
// external
// public
// internal
// private
// internal & private view & pure functions
// external & public view & pure functions
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
//import {VRFConsumerBaseV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol";
import {VRFConsumerBaseV2Plus} from "../lib/chainlink-brownie-contracts/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol";
import {VRFV2PlusClient} from "../lib/chainlink-brownie-contracts/contracts/src/v0.8/dev/vrf/libraries/VRFV2PlusClient.sol";
/**
* @title Raffle contract
* @author Rodion Lieno
* @notice This contract is a simple raffle system
* @dev Implements Chainlink VRFv2.5
*/
contract Raffle is VRFConsumerBaseV2Plus{
/* Errors */
error Raffle__SendMoreToEnterRaffle();
uint16 private constant REQUEST_CONFIRMATIONS = 3;
uint32 private constant NUM_WORDS = 1;
uint256 private immutable i_entranceFee;
// @dev The duratin of the lottery in seconds
uint256 private immutable i_interval;
bytes32 private immutable i_keyHash;
uint256 private immutable i_subscriptionId;
uint32 private immutable i_callbackGasLimit;
address payable [] private s_players;
uint256 private s_lastTimeStamp;
/* Events */
event RaffleEntered(address indexed player);
constructor(uint256 entranceFee, uint256 interval, address vrfCoordinator, bytes32 gasLane, uint256 subscriptionId, uint32 callbackGasLimit) VRFConsumerBaseV2Plus (vrfCoordinator) {
i_entranceFee = entranceFee;
i_interval = interval;
s_lastTimeStamp = block.timestamp;
i_keyHash = gasLane;
i_subscriptionId = subscriptionId;
i_callbackGasLimit = callbackGasLimit;
}
function enterRaffle() external payable {
//require(msg.value >= i_entranceFee, "Not enough ETH to enter the raffle");
//require(msg.value >= i_entranceFee, SendMoreToEnterRaffle());
if (msg.value < i_entranceFee) {
revert Raffle__SendMoreToEnterRaffle();
}
s_players.push(payable(msg.sender));
emit RaffleEntered(msg.sender);
}
function pickWinner() external {
if ((block.timestamp - s_lastTimeStamp) < i_interval) {
revert();
}
VRFV2PlusClient.RandomWordsRequest memory request = VRFV2PlusClient.RandomWordsRequest(
{
keyHash: i_keyHash, // gas price
subId: i_subscriptionId,
requestConfirmations: REQUEST_CONFIRMATIONS,
callbackGasLimit: i_callbackGasLimit, // gas limit
numWords: NUM_WORDS, // number pf random words
extraArgs: VRFV2PlusClient._argsToBytes(
//Set nativePayment to true to pay for VRF requests with Sepolia ETH instead of LINK
VRFV2PlusClient.ExtraArgsV1({nativePayment: false})
)
}
);
uint256 requestId = s_vrfCoordinator.requestRandomWords(request); // ERROR
}
/**
* Getter functions
*/
function fulfillRandomWords(uint256 requestId, uint256[] calldata randomWords) internal override {}
function getEntranceFee() external view returns (uint256) {
return i_entranceFee;
}
}
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Hey @Desertort, open |
Beta Was this translation helpful? Give feedback.
Hey @Desertort, open
VRFConsumerBaseV2Pluscontract and check what type iss_vrfCoordinator, most likely it will be the type ofIVRFCoordinatorV2Plus. Open theIVRFCoordinatorV2Plusinterface and check the path from which the interface importedVRFV2PlusClientstruct from then use that same path for the importing ofVRFV2PlusClientin yourRafflecontract, like that everything is supposed to work correctly.