Raffl
Git Source Inherits: ReentrancyGuardUpgradeable, EntriesManager, IRaffl 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.State Variables
factory
STATE Address of the RafflFactorycreator
User address that created the Rafflprizes
Prizes contained in the Raffldeadline
Block timestamp for when the draw should be made and until entries are acceptedminEntries
Minimum number of entries required to execute the drawentryPrice
Price of the entry to participate in the RafflentryToken
Address of the ERC20 entry token (if applicable)tokenGates
Array of token gates required for all participants to purchase entries.userRefund
Maps a user address to whether refund was made.extraRecipient
Extra recipient to share the pooled funds.pool
Total pooled funds from entries acquisitionsettled
Whether the raffle is settled or notprizesRefunded
Whether the prizes were refunded when criteria did not meet.gameStatus
Status of the Raffl gameMAX_ENTRIES_PER_USER
Maximum number of entries a single address can hold.MAX_TOTAL_ENTRIES
Maximum total of entries.ONE
Percentages and fees are calculated using 18 decimals where 1 ether is 100%.manager
The manager that deployed this contract which controls the values forfee
and feeCollector
.
Functions
onlyFactory
MODIFIERSconstructor
initialize
INITIALIZERcriteriaMet
METHODSdeadlineExpired
Checks if the deadline has passedupkeepPerformed
Checks if raffle already perfomed the upkeeppoolFeeData
Returns the current pool fee associated to thisRaffl
.
getPrizes
Returns the current prizes associated to thisRaffl
.
buyEntries
Purchase entries for the raffle. Handles the acquisition of entries for three scenarios: i) Entry is paid with network tokens, ii) Entry is paid with ERC-20 tokens, iii) Entry is free (allows up to 1 entry per user)Name | Type | Description |
---|---|---|
quantity | uint256 | The quantity of entries to purchase. Requirements: - If entry is paid with network tokens, the required amount of network tokens. - If entry is paid with ERC-20, the contract must be approved to spend ERC-20 tokens. - If entry is free, no payment is required. Emits EntriesBought event |
refundEntries
Refund entries for a specific user. Invokable when the draw was not made because the min entries were not enoughtName | Type | Description |
---|---|---|
user | address | The address of the user whose entries will be refunded. |
refundPrizes
Refund prizes to the creator. Invokable when the draw was not made because the min entries were not enought_transferPrizes
HELPERS Transfers the prizes to the specified user.Name | Type | Description |
---|---|---|
user | address | The address of the user who will receive the prizes. |
_transferPool
Transfers the pool balance to the creator of the raffle, after deducting any fees._purchaseEntry
Internal function to handle the purchase of entries with entry price greater than 0.Name | Type | Description |
---|---|---|
quantity | uint256 | The quantity of entries to purchase. |
_purchaseFreeEntry
Internal function to handle the purchase of free entries with entry price equal to 0._ensureTokenGating
Ensures that the user has all the requirements from thetokenGates
array
Name | Type | Description |
---|---|---|
user | address | Address of the user |
setSuccessCriteria
FACTORY METHODS Access control:factory
is the only allowed to called this method
setFailedCriteria
Sets the criteria as settled, sets theGameStatus
as FailedDraw
and emits event
DeadlineFailedCriteria
Access control: factory
is the only allowed to called this method
disperseRewards
Transfers theprizes
to the provably fair and verifiable entrant, sets the GameStatus
as
SuccessDraw
and emits event DrawSuccess
Access control: factory
is the only allowed to called this method through the Chainlink VRF Coordinator