NatSpec
Solidity API
DeRafl
This contract is used by DeRafl to hold raffles for any erc721 token
Designed to be as trustless as possible. There are no owner functions. Chainlink VRF is used to determine a winning ticket of a raffle. A refund for a raffle can be initiated 2 days after a raffles expiry date if not already released. LooksRare royaltyFeeRegistry is used to determine royalty rates for collections. Collection royalties are honoured with a max payout of 10%
INTERFACE_ID_ERC721
ERC721 interface
MIN_DAYS
Minimum days a raffle can be active
MAX_DAYS
Maximum days a raffle can be active
MIN_ETH
Minimum amount of Eth
MAX_ETH
Maximum amount of Eth
MAX_ROYALTY_FEE_PERCENTAGE
Maximum royalty fee percentage (10%)
DERAFL_FEE_PERCENTAGE
DeRafl protocol fee (3%)
DERAFL_CHAINLINK_FEE
DeRafl Chainlink Fee
TICKET_PRICE
Price per ticket
subscriptionId
vrfCoordinator
keyHash
callbackGasLimit
requestConfirmations
numWords
COORDINATOR
RaffleOpened
Emitted when a raffle is created
Parameters
raffleId
uint256
The id of the raffle created
nftAddress
address
The address of the NFT being raffled
tokenId
uint256
The tokenId of the NFT being raffled
tickets
uint256
Maximum amount of tickets to be sold
expires
uint256
The timestamp when the raffle expires
RaffleClosed
Emitted when a raffle is closed
Parameters
raffleId
uint256
The id of the raffle being closed
RaffleDrawn
Emitted when a raffle is drawn and winning ticket determined
Parameters
raffleId
uint256
The id of the raffle being drawn
winningTicket
uint256
The winning ticket of the raffle being drawn
RaffleReleased
Emitted when a raffle is released
Parameters
raffleId
uint256
The id of the raffle being released
winner
address
The address of the winning ticket holder
royaltiesPaid
uint256
Collection royalties paid in wei
ethPaid
uint256
Ethereum paid to the raffle owner in wei
RaffleRefunded
Emitted when a raffle has been changed to a refunded state
Parameters
raffleId
uint256
The id of the raffle being refunded
TicketPurchased
Emitted when tickets are purchased
Parameters
raffleId
uint256
The raffle id of the tickets being purchased
batchId
uint256
The batch id of the ticket purchase
purchaser
address
The address of the account making the purchase
ticketFrom
uint256
The first ticket of the ticket batch
ticketAmount
uint256
The amount of tickets being purchased
TicketRefunded
Emitted when a refund has been placed
Parameters
raffleId
uint256
The raffle id of the raffle being refunded
refundee
address
The account being issued a refund
ethAmount
uint256
The ethereum amount being refunded in wei
RaffleState
TicketOwner
TicketBatch
Raffle
royaltyFeeRegistry
LooksRare royaltyFeeRegistry
raffles
mapping of raffleId => raffle
ticketOwners
maps a participants TOTAL tickets bought for a raffle
ticketBatches
maps ticketBatches purchased for a raffle
chainlinkRequestIdMap
maps raffleId to a chainlink VRF request
raffleNonce
incremented raffleId
deraflFeeCollector
address to collect protocol fee
constructor
getRaffle
DeRafl Returns information about a particular raffle
Returns the Raffle struct of the specified Id
Parameters
raffleId
uint256
a parameter just like in doxygen (must be followed by parameter name)
Return Values
rafl
struct DeRafl.Raffle
the Raffle struct at the specified raffleId
getUserInfo
DeRafl Returns an accounts particiaption for a raffle
TicketOwner contains the total amount of tickets bought for a raffle (sum of all ticket batches) and the refund status of a participant in the raffle
Parameters
raffleId
uint256
The raffle Id of the raffle being queried
ticketOwner
address
The address of the participant being queried
Return Values
[0]
struct DeRafl.TicketOwner
TicketOwner
getBatchInfo
DeRafl Information about a specific TicketBatch for a raffle
Finds the TicketBatch for a specific raffle via the ticketBatches mapping
Parameters
raffleId
uint256
The raffle Id of the TicketBatch being queried
batchId
uint256
The batchId for the TicketBatch being queried
Return Values
[0]
struct DeRafl.TicketBatch
TicketBatch
createRaffle
DeRafl Creates a new raffle
Creates a new raffle and adds it to the raffles mapping
Parameters
nftAddress
address
The address of the NFT being raffled
tokenId
uint256
The token id of the NFT being raffled
daysActive
uint256
How many days until the raffle expires
ethInput
uint256
The maximum amount of Eth to be raised for the raffle
buyTickets
DeRafl Purchase tickets for a raffle
Allows a user to purchase a ticket batch for a raffle. Validates the raffle state. Refunds extra Eth if overpayed, or if tickets remaining < tickets intended to purchase. Creates a new ticketBatch and adds to ticketBatches mapping. Increments ticketOwner in ticketOwners mapping. Update state of Raffle with specified raffleId. Emit TicketsPurchased event.
Parameters
raffleId
uint256
The address of the NFT being raffled
ticketAmount
uint256
The amount of tickets to purchase
drawRaffle
DeRafl starts the drawing process for a raffle
Sends a request to chainlink VRF for a random number used to draw a winner. Validates raffleState is closed (sold out), or raffle is expired. Stores the chainlinkRequestId in chainlinkRequestIdMap against the raffleId. emits raffle closed event.
Parameters
raffleId
uint256
The raffleId of the raffle being drawn
release
Completes a raffle, releases prize and accumulated Eth to relevant stake holders
Validates that the batch referenced includes the winning ticket Validates raffle state is drawn
Parameters
raffleId
uint256
The raffle Id of the raffle being released
batchId
uint256
The batch Id of the batch including the winning ticket
refundRaffle
Changes a raffles state to REFUNDED, allowing participants to be issued refunds. A raffle can be refunded 2 days after it has expired, and is not in a RELEASED state
Parameters
raffleId
uint256
The raffle id of the raffle being refunded
refundTickets
Issues a refund to an individual participant for all tickets purchased (sum of all ticket batches)
Parameters
raffleId
uint256
The raffle id of the raffle being refunded
claimRefundedNft
Returns the NFT of a refunded raffle to the raffle owner
Parameters
raffleId
uint256
The raffle id of the raffle
getRoyaltyInfo
Gets the royalty fee percentage of an nft. Returns a maximum of 10%
Parameters
nftAddress
address
The address of the token being queried
requestRandomNumber
Requests a random number from chainlink VRF
Return Values
[0]
uint256
chainlinkRequestId of the request
fulfillRandomWords
DeRafl Callable by chainlink VRF to receive a random number
Generates a winning ticket number between 0 - tickets sold for a raffle
Parameters
requestId
uint256
The chainlinkRequestId which maps to raffle id
randomWords
uint256[]
random words sent by chainlink
onERC721Received
Last updated