> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raffl.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Subgraph

### Built With

* [TheGraph](https://thegraph.com/)
* And with ❤️

### TheGraph Subgraph URL:

<table>
  <thead>
    <tr>
      <th width="145">Network</th>
      <th width="145">ChainID</th>
      <th>Subgraph</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Sepolia</td>
      <td>11155111</td>

      <td>
        <a href="https://thegraph.com/explorer/subgraphs/D9Gqgx33iq8L6W3JVTxYreaU7w8pRGFpUs44Cui9sUdF?view=Overview&chain=arbitrum-one">D9Gqgx33iq8L6W3JVTxYreaU7w8pRGFpUs44Cui9sUdF</a>
      </td>
    </tr>

    <tr>
      <td>Arbitrum</td>
      <td>42161</td>

      <td>
        <a href="https://thegraph.com/explorer/subgraphs/7FsGux71c4UrU8hAj9LdeC4cghL5Ye3GxXbt7LHCJs1N?v=0&view=Overview&chain=arbitrum-one">7FsGux71c4UrU8hAj9LdeC4cghL5Ye3GxXbt7LHCJs1N</a>
      </td>
    </tr>

    <tr>
      <td>Polygon</td>
      <td>137</td>

      <td>
        <a href="https://thegraph.com/explorer/subgraphs/5KdktDzHygaRe4RXwi1XjkU48HG2kpBp2dCgdnyGdxeg?view=Overview&chain=arbitrum-one">5KdktDzHygaRe4RXwi1XjkU48HG2kpBp2dCgdnyGdxeg</a>
      </td>
    </tr>

    <tr>
      <td>Polygon Amoy</td>
      <td>80002</td>

      <td>
        <a href="https://thegraph.com/explorer/subgraphs/3f4Xu5Ws33rWv666JpVgiionCWs3StfAT9r84rpwmWVq?view=Overview&chain=arbitrum-one">3f4Xu5Ws33rWv666JpVgiionCWs3StfAT9r84rpwmWVq</a>
      </td>
    </tr>
  </tbody>
</table>

## Queries

### Query many raffles

Get raffles

```graphql theme={null}
{
  raffles(first: 1000, skip: 0) {
    id
    entryPrice
    minEntries
    prizes {
      asset
      type
      value
      name
      symbol
      decimals
      uri
    }
    creator {
      id
    }
    participantsCount
    participants {
      user {
        id
      }
      blockTimestamp
    }
    deadline
    state
    result {
      winner {
        id
      }
      drawSuccess {
        blockTimestamp
        transactionHash
      }
    }
    creation {
      blockTimestamp
      transactionHash
    }
  }
}
```

### Query one raffle

Get one raffle

```graphql theme={null}
{
  raffle(id: "0xb374575756c701209a219158934ec2d763d46509") {
    networkId
    id
    entryPrice
    minEntries
    prizes {
      asset
      type
      value
      name
      symbol
      decimals
      uri
    }
    creator {
      id
    }
    participantsCount
    participants {
      user {
        id
      }
      blockTimestamp
    }
    deadline
    state
    result {
      winner {
        id
      }
      drawSuccess {
        blockTimestamp
        transactionHash
      }
    }
    creation {
      blockTimestamp
      transactionHash
    }
  }
}
```

### Query a raffle activity

Get all the activity from a raffle

```graphql theme={null}
{
  entries(where: { raffle: "0xb374575756c701209a219158934ec2d763d46509" }) {
    user {
      id
    }
    quantity
    total
    boughtEvent {
      blockTimestamp
      transactionHash
    }
  }
  deadlineFailedCriterias(
    where: { raffle: "0xb374575756c701209a219158934ec2d763d46509" }
  ) {
    entries
    transactionHash
    blockTimestamp
  }
  deadlineSuccessCriterias(
    where: { raffle: "0xb374575756c701209a219158934ec2d763d46509" }
  ) {
    entries
    transactionHash
    blockTimestamp
  }
}
```

### Query a raffle refunds

Get the user refunds from a raffle

```graphql theme={null}
{
  raffle(id: $address) {
    prizesRefunded {
      blockTimestamp
      transactionHash
    }
    participants(where: { user: $userAddress }) {
      id
    }
    entriesRefunded(where: { user: $userAddress }) {
      entriesRefunded
      blockTimestamp
      transactionHash
    }
  }
}
```
