You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 17, 2024. It is now read-only.
When I try to compile my code, there's an error in the function checkUpkeep and performUpkeep about calldata and memory. There are some libraries of Chainlink that change it, so I don't know how to fix. There's the code:
// SPDX-License-Identifier: MITpragma solidity^0.8.7;
import"@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
import"@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface.sol";
import"@chainlink/contracts/src/v0.8/vrf/KeepersVRFConsumer.sol";
error Raffle__NotEnoughETHEntered();
error Raffle__TransferFailed();
error Raffle__NotOpen();
error Raffle_UpkeepNotNeeded(uint256currentBalnce, uint256numPlayers, uint256raffleState);
contractRaffleisVRFConsumerBaseV2, KeeperCompatibleInterface {
enum RaffleState {
OPEN,
CALCULATING
}
uint256privateimmutable i_entranceFee;
address payable[] private s_players;
VRFCoordinatorV2Interface privateimmutable i_vrfCoordinator;
bytes32privateimmutable i_gasLane;
uint64privateimmutable i_subscriptionId;
uint32privateimmutable i_callbackGasLimit;
uint16private constant REQUEST_CONFIRMATIONS =3;
uint32private constant NUM_WORDS =1;
addressprivate s_recentWinner;
RaffleState private s_raffleState;
uint256private s_lastTimeStamp;
uint256privateimmutable i_interval;
event RaffleEnter(addressindexedplayer);
event RequestedRaffleWinner(uint256indexedrequestId);
event WinnerPicked(addressindexedwinner);
constructor(
addressvrfCoordinatorV2,
uint256entranceFee,
bytes32gasLane,
uint64subscriptionId,
uint32callbackGasLimit,
uint256interval
) VRFConsumerBaseV2(vrfCoordinatorV2) {
i_entranceFee = entranceFee;
i_vrfCoordinator =VRFCoordinatorV2Interface(vrfCoordinatorV2);
i_gasLane = gasLane;
i_subscriptionId = subscriptionId;
i_callbackGasLimit = callbackGasLimit;
s_raffleState = RaffleState.OPEN;
s_lastTimeStamp =block.timestamp;
i_interval = interval;
}
function enterRaffle() publicpayable {
if (msg.value< i_entranceFee) {
revertRaffle__NotEnoughETHEntered();
}
if (s_raffleState != RaffleState.OPEN) {
revertRaffle__NotOpen();
}
s_players.push(payable(msg.sender));
emitRaffleEnter(msg.sender);
}
/** * @dev This is the function that the Chainlink Keeper nodes call * they look for the `upkeepNeeded` to return true. * The following should be true in order to be return true; * 1. Our time interval should have passed * 2. The lottery should have at least 1 player, and have some ETH * 3. Our subscription is funded with LINK * 4. The lottery should be in "open" state */function checkUpkeep(
bytescalldata/*checkData*/
) publicoverridereturns (boolupkeepNeeded, bytesmemory/* performData */) {
bool isOpen = (RaffleState.OPEN == s_raffleState);
bool timePassed = (block.timestamp- s_lastTimeStamp) > i_interval;
bool hasPlayers = (s_players.length>0);
bool hasBalance =address(this).balance >0;
upkeepNeeded = (isOpen && timePassed && hasPlayers && hasBalance);
}
function performUpkeep(bytescalldata/*performData*/) externaloverride {
(boolupkeepNeeded, ) =checkUpkeep("");
if (!upkeepNeeded) {
revertRaffle_UpkeepNotNeeded(
address(this).balance,
s_players.length,
uint256(s_raffleState)
);
}
s_raffleState = RaffleState.CALCULATING;
uint256 requestId = i_vrfCoordinator.requestRandomWords(
i_gasLane,
i_subscriptionId,
REQUEST_CONFIRMATIONS,
i_callbackGasLimit,
NUM_WORDS
);
emitRequestedRaffleWinner(requestId);
}
function fulfillRandomWords(
uint256/*requestId*/,
uint256[] memoryrandomWords
) internaloverride {
uint256 indexOfWinner = randomWords[0] % s_players.length;
address payable recentWinner = s_players[indexOfWinner];
s_recentWinner = recentWinner;
s_raffleState = RaffleState.OPEN;
s_players =newaddress payable[](0);
s_lastTimeStamp =block.timestamp;
(boolsuccess, ) = recentWinner.call{value: address(this).balance}("");
if (!success) {
revertRaffle__TransferFailed();
}
emitWinnerPicked(recentWinner);
}
function getEntranceFee() publicviewreturns (uint256) {
return i_entranceFee;
}
function getPlayer(uint256index) publicviewreturns (address) {
return s_players[index];
}
function getRecentWinner() publicviewreturns (address) {
return s_recentWinner;
}
}
And the problem is:
Invalid type for argument in function call. Invalid implicit conversion from literal_string "" to bytes calldata requested.
The text was updated successfully, but these errors were encountered:
When I try to compile my code, there's an error in the function checkUpkeep and performUpkeep about calldata and memory. There are some libraries of Chainlink that change it, so I don't know how to fix. There's the code:
And the problem is:
The text was updated successfully, but these errors were encountered: