# How to Verify Winner from VRF

### 🧠 What is VRF?

**Chainlink VRF** provides a **provably random number** generated off-chain and verified **on-chain** using a cryptographic proof.\
This ensures:

* 🧾 Fairness — no one can predict or influence the result.
* 🔍 Transparency — anyone can verify the winning ticket and VRF response.
* 🔒 Security — randomness cannot be reused or modified once committed.

### 🧩 When VRF is Used in Raflux

After a raffle ends:

1. The `RaffleManager` contract requests randomness from Chainlink.
2. VRF generates a random number and returns it to the contract via callback.
3. The contract calculates the **winning ticket ID**
4. The winning ticket’s owner is set as the **winner** for that raffle.

> ⚙️ All of this happens automatically — no human involvement.

### 🪄 Step-by-Step: How to Verify Winner

Follow these steps using **BaseScan (Base Etherscan)**:

#### 1️⃣ Open the Tx Hash from “Rolled Item” on BaseScan

After a raffle finishes rolling, open the **transaction hash** (Tx Hash) linked to that **Rolled Item** in the Raflux dashboard.

This is the transaction that called Chainlink VRF and finalized the raffle draw.

> 💡 You can find this Tx Hash in the Raffle Detail page under **Result**.

#### 2️⃣ Open the Logs Tab

Once inside the transaction page, click the **Logs** tab (next to Overview).

This tab displays every on-chain event emitted during that transaction.

#### 3️⃣ Check the **Transaction Receipt Event Logs**

Look for an event named:

```
TicketRolled(
  uint256 tokenId,
  address asset,
  address vrfConsumer,
  address vrfCoordinator,
  address pool
)
```

🧩 The `pool` and `vrfConsumer` address is the **addresses** you’ll need for the next step.

#### 4️⃣ Copy the `vrfConsumer` and `pool` Addresses

| Field       | Purpose                                                           |
| ----------- | ----------------------------------------------------------------- |
| vrfConsumer | Contract that stores VRF results (where you’ll query the winner). |
| pool        | The specific raffle’s pool address (used as input for query).     |

#### 5️⃣ Open the VRF Consumer Contract

Go to **BaseScan** and open the `vrfConsumer` contract address you copied.\
This contract holds the official **VRF results** verified and fulfilled by Chainlink.

#### 6️⃣ Open the **Contract → Read Contract** Tab

Inside the Contract tab, select **“Read Contract”**.\
This allows you to view public on-chain data without sending a transaction.

> 🔓 No gas or wallet connection is required to read this data.

#### 7️⃣ Find the `results` Function

Scroll down the list of available functions and locate:

```
function results(address rafflePool) public view returns (address winner)
```

This function returns the **winner address** for a specific raffle.

#### 8️⃣ Paste the Pool (Raffle) Address

Paste the **pool address** (from Step 4) into the input box.

#### 9️⃣ Click **Query**&#x20;

Press the **Query** button to execute a read-only call.

🎉 That’s your **verified winner address** — fetched directly from the blockchain, confirmed by Chainlink VRF.
