# Raffle Lifecycle

{% stepper %}
{% step %}

### Asset Listing

The seller creates a new raffle by locking an NFT or token into the **EscrowVault** smart contract.

They define:

* 🎯 **Target amount** — minimum goal for successful raffle.
* 🎟️ **Ticket supply** — total number of NFT tickets.
* ⏱️ **Timeframe** — 7, 14, or 30 days.

Once listed:

* The asset is transferred to the escrow contract.
* A new `raffleId` is generated and registered in `RaffleManager.sol`.
* The raffle’s initial **status = Listed**.
  {% endstep %}

{% step %}

### Ticket Sale

When the raffle goes live:

* Users can start buying NFT tickets.
* Each purchase mints an **ERC-1155 ticket** (fungible-per-raffle model).
* Payment accepted in U**SDT**.
  {% endstep %}

{% step %}

### Raffle Close

When the timeframe ends or sold out:

#### ✅ Case 1 — Target Met

* **Asset** transferred from escrow to the randomly selected **winner**.
* **Seller** receives **90%** of total collected funds.
* **Platform** receives **10%** fee.
* Status becomes: **Item Raffled**

#### ⚖️ Case 2 — Target Unmet (Partial or No Sell)

If the goal isn’t reached:

* Collected funds are raffled among ticket holders instead of the asset.
* **Winner** receives **95%** of raised funds.
* **5%** fee sent to platform wallet.
* Status becomes: **Fund Raffled**

#### 🚫 Case 3 — No Tickets Sold / Cancelled Raffle

If no ticket is sold:

* Seller can **claim back** the locked asset from escrow.
* No funds are exchanged.
* Status becomes: **Cancelled**
  {% endstep %}

{% step %}

### Winner Selection

Raflux uses **Chainlink VRF** to ensure randomness is verifiable and tamper-proof.
{% endstep %}

{% step %}

### Prize Claim

Once a winner is determined:

* The **winning wallet** can call the claim function to receive the prize.

#### Claim Scenarios

| Scenario            | Claim Result                                     |
| ------------------- | ------------------------------------------------ |
| 🎁 **Item Raffled** | Winner receives NFT or token asset.              |
| 💰 **Fund Raffled** | Winner receives raised fund balance (after fee). |
| 🚫 **Cancelled**    | Seller reclaims original asset.                  |
| {% endstep %}       |                                                  |
| {% endstepper %}    |                                                  |

#### 🧾 Status Explanation <a href="#status-explanation" id="status-explanation"></a>

|                     |                                                                                |                                                     |
| ------------------- | ------------------------------------------------------------------------------ | --------------------------------------------------- |
| 🟢 **Listed**       | Raffle is created and ticket sale is ongoing.                                  | Seller lists asset and buyers can purchase tickets. |
| 🟡 **Raffling**     | Raffle ended; waiting for Chainlink VRF result (winner selection in progress). | Raffle duration ends/ticket sold out.               |
| 🟣 **Item Raffled** | Target met, asset distributed to winner.                                       | VRF selection complete.                             |
| 🔵 **Fund Raffled** | Target unmet, funds distributed to winner.                                     | VRF selection complete.                             |
| 🔴 **Cancelled**    | No sale or cancelled raffle, asset returned to seller.                         | Seller/admin action.                                |
