Rafle States

This document describes the different states that a raffle can assume using the DeRafl protocol.

In our endeavour to remain as decentralized as possible, we have made all functions which change the state of a raffle to be "unowned". This means that anyone can create, close, draw and release any raffle, as long as the pre-determined on-chain checks and balances are met for each change of state.

This means that once a raffle has been created, it is 100% controlled by the code in the smart contract, and the actions of the community. By designing our smart contract this way, we can ensure that no-one can simply abandon a raffle, leaving participants without a winner, and losing Ethereum in the process.

  • Active A raffle always starts off in an active state. The raffle creator has committed their asset that they wish to raffle to be held in the DeRafl smart contract in escrow. The raffle now has an expiry date (between 1-14 days from the creation of the raffle), and maximum ticket amount. The raffle will stay in an active state until either the maximum amount of tickets are sold, or the current date exceeds the expiry date. Tickets can only be purchased when a raffle is in an active state. All Ethereum received for ticket purchases is also held in escrow in the DeRafl smart contract until the raffle is in a Released state

  • Closed A raffle is considered closed when either the maximum amount of tickets are sold out, or the current date exceeds the expiry date. Once a raffle is in closed state, the drawRaffle function can be called on the DeRafl smart contract. This function will submit a request to chainlink VRF to generate a random number and draw a winner of the raffle. The Chainlink VRF process does not happen immediately, and will take place in a transaction in a future block. Generally this takes place in 3-10 blocks but can sometimes take longer in times of high gas prices. You can read more about Chainlink VRF here https://docs.chain.link/vrf/v2/introduction/.

  • Pending Draw A raffle is in a pending draw state once the request to Chainlink VRF has been sent by the DeRafl contract, and the DeRafl contract is now awaiting a response from Chainlink. The Chainlink VRF will call the DeRafl contract using the fulfillRandomWords function. The input of this function is used to determine the winning ticket of the raffle, between 1 and the number of tickets sold. The winning ticket number of the raffle is then stored in the DeRafl smart contract.

  • Drawn A raffle is in a drawn state once Chainlink has responded to the request for a random number and a winning ticket number has been determined. The owner of the winning ticket is found by determining which ticket batch included the winning ticket, and which address owned that ticket batch. Once the winning ticket batch has been determined, the release function can be called on the DeRafl smart contract. The winning ticket batch (batchId) is passed to this function, and the smart contract will determine that the batchId passed in includes the winning ticket number provided by Chainlink VRF. If the input of the release function passes all checks, then the asset being raffled will be transferred to the winner, and the Ethereum generated will be sent to the raffle owner minus protocol and royalty fees.

  • Released A raffle is considered released once the asset being raffled has been successfully transferred to the winner of the raffle, and the Ethereum held for a raffle has been released. Once a raffle is in a released state, no further actions can be taken on a raffle, a raffle is considered complete.

  • Refunded In the event that an asset cannot be released by the DeRafl contract, a raffle can be moved to a Refunded state. This could potentially happen when someone raffles an asset which has a blacklist, or some type of malicious code which prevents an asset from being transferred. To protect users of the DeRafl protocol, we want to make sure that participants of the raffle can receive a refund in this unfortunate event. A raffle can only be refunded 2 days after the expiry date of a raffle, and only if the raffle has not moved to a Released state.

Last updated