Skip to main content

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 RafflFactory

creator

User address that created the Raffl

prizes

Prizes contained in the Raffl

deadline

Block timestamp for when the draw should be made and until entries are accepted

minEntries

Minimum number of entries required to execute the draw

entryPrice

Price of the entry to participate in the Raffl

entryToken

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 acquisition

settled

Whether the raffle is settled or not

prizesRefunded

Whether the prizes were refunded when criteria did not meet.

gameStatus

Status of the Raffl game

MAX_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 for fee and feeCollector.

Functions

onlyFactory

MODIFIERS

constructor

initialize

INITIALIZER

criteriaMet

METHODS

deadlineExpired

Checks if the deadline has passed

upkeepPerformed

Checks if raffle already perfomed the upkeep

poolFeeData

Returns the current pool fee associated to this Raffl.

getPrizes

Returns the current prizes associated to this Raffl.

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)
Parameters

refundEntries

Refund entries for a specific user. Invokable when the draw was not made because the min entries were not enought
Parameters

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.
Parameters

_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.
Parameters

_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 the tokenGates array
Parameters

setSuccessCriteria

FACTORY METHODS Access control: factory is the only allowed to called this method

setFailedCriteria

Sets the criteria as settled, sets the GameStatus as FailedDraw and emits event DeadlineFailedCriteria Access control: factory is the only allowed to called this method

disperseRewards

Transfers the prizes 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