# Fairness Verification

## Overview

MemeDice has a built-in fairness verification tool that allows anyone to independently verify the randomness and fairness of game results. The verification method depends on the random number mode used by the game:**Oracle mode** or **Prevrandao mode**.

***

## How to access the verification tool

1. Visit any MemeDice game (such as `xxx.dapp.meme`)
2. Click the **"📋 Logs"** Tag
3. in the top navigation bar **switch to the** "🔍 Verification"

<figure><img src="/files/b7abd290ab99c304f579d0ee8a33c465e55536f3" alt=""><figcaption></figcaption></figure>

***

## tab

Oracle mode verification **commit-reveal** mechanism to generate random numbers, which is a cryptographically verified fair randomness scheme.

### Verification principle

```mermaid
sequenceDiagram
    participant Player as Player
    participant Contract as Game contract
    participant Oracle as Oracle service

    Note over Oracle: 1. Generate random number R
    Note over Oracle: 2. Compute commitHash = keccak256(R)
    Oracle->>Player: Return commitHash + signature
    Player->>Contract: Submit bet + commitHash
    Note over Contract: Lock commitHash
    Oracle->>Contract: Reveal random number R
    Note over Contract: 3. Verify keccak256(R) == commitHash ✅
    Note over Contract: 4. Use R to determine the result
```

### Verification steps

1. **Get bet information**: Find the bet to verify in the betting records and note its `requestId`
2. **View commitHash**: The bet transaction contains the Oracle's previously committed `commitHash`
3. **View the revealed random number**: The random number later submitted by the Oracle `R`
4. **Independent verification**: Calculate `keccak256(R)` to see whether it equals `commitHash`

```
Verification formula: keccak256(randomNumber) == commitHash
```

If the equation holds, it means:

* The Oracle had already determined the random number **before** the player placed the bet (locked in through commitHash)
* Oracle **cannot** modify the random number after seeing the player's bet
* The random number is fair

### Use the verification tool

On the Verification tab:

1. Enter the **Request ID** or **transaction hash**
2. The tool will automatically fetch `commitHash` and `randomNumber`
3. and automatically calculate and display the verification result: ✅ Pass / ❌ Fail

<figure><img src="/files/120df418ab81bcb730c06cdc4d9e65900a867cb0" alt=""><figcaption></figcaption></figure>

***

## Prevrandao mode verification

Prevrandao mode uses Ethereum's `block.prevrandao` value as the source of randomness.

### Verification principle

```
Random number = block.prevrandao (the prevrandao value of the block containing the bet transaction)
```

### Verification steps

1. **Get the bet transaction hash**: Find the transaction hash in the betting records
2. **View the block number**: Use a block explorer to check the block number where the transaction was included
3. **Get prevrandao**: View the `prevrandao` value for that block
4. **Verification result**: Confirm that the random number used by the contract matches the block's `prevrandao` value

### Verify through a block explorer

1. In [Etherscan](https://etherscan.io/) search for the transaction hash
2. Click the block number to enter the block details
3. View the `Difficulty` field (after PoS, it is `prevrandao`)
4. Compare the random number recorded in the contract event

<figure><img src="/files/9220d415ab779d146c183e4e96d861808e1d2e89" alt=""><figcaption></figcaption></figure>

***

## Result determination verification

No matter which random number mode is used, the result-determination logic is the same:

```
Threshold = 10000 - winRateParam

If betting big (betOnBig = true):
  randomNumber % 10000 >= threshold → win
  randomNumber % 10000 < threshold → lose

If betting small (betOnBig = false):
  randomNumber % 10000 < winRateParam → win
  randomNumber % 10000 >= winRateParam → lose
```

### Verification example

| Parameter     | value for that block |
| ------------- | -------------------- |
| Random number | 123456789            |
| winRateParam  | 5000 (50%)           |
| Direction     | Bet big              |

```
Threshold = 10000 - 5000 = 5000
randomNumber % 10000 = 123456789 % 10000 = 6789
6789 >= 5000 → ✅ Win!
```

***

## Why can it be trusted?

### Security guarantees of Oracle mode

| Guarantees             | Description                                                                                                   |
| ---------------------- | ------------------------------------------------------------------------------------------------------------- |
| **Unpredictable**      | The random number is determined when the commitHash is submitted, so players cannot predict it                |
| **Unmodifiable**       | The Oracle cannot modify the random number after seeing the bet (the commitHash is already locked)            |
| **Verifiable**         | Anyone can verify `keccak256(R) == commitHash`                                                                |
| **Timeout protection** | If the Oracle does not reveal the random number, funds are automatically returned by the Oracle after timeout |

### Security guarantees of Prevrandao mode

| Guarantees                            | Description                                                                                 |
| ------------------------------------- | ------------------------------------------------------------------------------------------- |
| **On-chain native**                   | The random number comes from the Ethereum protocol layer and does not rely on third parties |
| **Unpredictable**(for ordinary users) | Ordinary users cannot predict the prevrandao of the next block                              |
| **Verifiable**                        | Anyone can verify through a block explorer                                                  |
| **EOA restriction**                   | Contracts cannot call it, preventing flash-loan attacks                                     |

***

## Common verification questions

### Q: What if verification fails?

Verification failure means `keccak256(randomNumber) != commitHash`, which should not happen under normal circumstances. If you encounter a verification failure:

1. Confirm whether the Request ID or transaction hash you entered is correct
2. Confirm whether the network is correct (BSC / Ethereum)
3. If everything is correct but verification still fails, please contact the platform team

### Q: How do you verify batch bets?

Batch bets use the same random number, but generate different results for each bet through different calculation methods:

```
Result of the 1st bet = randomNumber % 10000
Result of the 2nd bet = (randomNumber / 10000) % 10000
Result of the 3rd bet = (randomNumber / 10000^2) % 10000
...
```

### Q: Why do some bets not have a commitHash?

Using **Prevrandao mode** the bet does not need a commitHash because the random number comes directly from the block's `prevrandao` value.

***

## Related links

* ⬅️ Back [Leaderboard and logs overview](/dapp.meme-en/leaderboard-and-logs/leaderboard-and-logs-overview.md)
* 🎲 Learn about [Oracle vs Prevrandao](/dapp.meme-en/technical-overview/oracle-vs-prevrandao.md)
* 🔒 Learn about [Prevrandao Security](file:///7303089/deep-dive/prevrandao-security.md)
* 🛡️ Learn about [Game Security](/dapp.meme-en/technical-overview/game-security.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dapp.meme/dapp.meme-en/leaderboard-and-logs/fairness-verification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
