RafflFactory
Git Source Inherits: AutomationCompatibleInterface, VRFConsumerBaseV2Plus, FactoryFeeManager Author: JA (@ubinatus) Raffl is a decentralized platform built on the Ethereum blockchain, allowing users to create and participate in raffles/lotteries with complete transparency, security, and fairness. The RafflFactory contract can be used to create raffle contracts, leveraging Chainlink VRF and Chainlink Automations.State Variables
keyHash
Max gas to bump tocallbackGasLimit
Callback gas limit for the Chainlink VRFrequestConfirmations
Number of requests confirmations for the Chainlink VRFsubscriptionId
Chainlink subscription IDimplementation
The address that will be used as a delegate call target forRaffls.
_salt
It will be used as the salt for create2_raffles
Maps the createdRaffls addresses
_requestIds
Maps the VRFrequestId to the Raffls address
_activeRaffles
Stores the active raffles, which upkeep is pending to be performedFunctions
constructor
*Creates aRaffl factory contract.
Requirements:
implementationAddresshas to be a contract.feeCollectorAddresscan’t be address 0x0.poolFeePercentagemust be within 0 and maxFee range.vrfCoordinatorcan’t be address 0x0.*
nextSalt
Increments the salt one step.createRaffle
Creates newRaffl contracts.
Requirements:
underlyingTokenAddresscannot be the zero address.timestampsmust be given in ascending order.percentagesmust be given in ascending order and the last one must always be 1 eth, where 1 eth equals to 100%.
activeRaffles
Exposes theActiveRaffles
handleSubscription
Sets the Chainlink VRF subscription settingscheckUpkeep
Method called by the Chainlink Automation Nodes to check ifperformUpkeep must be done.
Performs the computation to the array of _activeRaffles. This opens the possibility of having several
checkUpkeeps done at the same time.
Returns
performUpkeep
Permissionless write method usually called by the Chainlink Automation Nodes. Either starts the draw for a raffle or cancels the raffle if criteria is not met.fulfillRandomWords
Method called by the Chainlink VRF Coordinator_burnActiveRaffle
Helper function to remove a raffle from the_activeRaffles array
Move the last element to the deleted stop and removes the last element
setFeeCollector
FUNCTIONS *Set address of fee collector. Requirements:msg.senderhas to be the owner of the factory.newFeeCollectorcan’t be address 0x0.*
Events
RaffleCreated
Structs
ActiveRaffle
raffle the address of the raffle
deadline is the timestamp that marks the start time to perform the upkeep effect.