---
# System prepended metadata

title: Querying BetSwirl

---

# Querying BetSwirl

You can build your own queries using a [GraphQL Explorer](https://graphiql-online.com/graphiql) and enter your endpoint to limit the data to exactly what you need.

Each entity has a plural version and a singular version. When querying for a single record response (e.g. account), you will need to supply the id for the entity. When querying for a list of responses (e.g. accounts), you may add filters using the 'where' clause.

Below are some sample queries you can use to gather information from the BetSwirl contracts.

## Examples

### The query below shows results from first 5 stores factories and 5 tokens

```graphql
{
  stores(first: 5) {
    id
    tokens {
      id
    }
    bets
    users
  }
  tokens(first: 5) {
    id
    updatedAt
    store {
      id
    }
    bets
  }
}
```

### Returns

```graphql
{
  "data": {
    "stores": [
      {
        "id": "0",
        "tokens": [
          {
            "id": "0x0000000000000000000000000000000000000000"
          },
          {
            "id": "0x8f47416cae600bccf9530e9f3aeaa06bdd1caa79"
          },
          {
            "id": "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e"
          },
          {
            "id": "0xc763f8570a48c4c00c80b76107cbe744dda67b79"
          }
        ],
        "bets": "277377",
        "users": "3312"
      }
    ],
    "tokens": [
      {
        "id": "0x0000000000000000000000000000000000000000",
        "updatedAt": "1662728438",
        "store": {
          "id": "0"
        },
        "bets": "197459"
      },
      {
        "id": "0x8f47416cae600bccf9530e9f3aeaa06bdd1caa79",
        "updatedAt": "1662728902",
        "store": {
          "id": "0"
        },
        "bets": "78381"
      },
      {
        "id": "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
        "updatedAt": "1655775126",
        "store": {
          "id": "0"
        },
        "bets": "17"
      },
      {
        "id": "0xc763f8570a48c4c00c80b76107cbe744dda67b79",
        "updatedAt": "1662728727",
        "store": {
          "id": "0"
        },
        "bets": "1520"
      }
    ]
  }
```

### High cap low amount Dice bets

```graphql
{
  diceBets(
    where: {
      cap_gt: 50
      timestamp_gt: "1655085264"
      gameToken_contains: "0x0000000000000000000000000000000000000000"
    }
    orderBy: amount
    orderDirection: asc
    first: 3
  ) {
    amount
    gameToken {
      game
      token {
        id
      }
    }
  }
}
```

### Return

```graphql
{
  "data": {
    "diceBets": [
      {
        "amount": "1000000000000",
        "gameToken": {
          "game": "Dice",
          "token": {
            "id": "0x0000000000000000000000000000000000000000"
          }
        }
      },
      {
        "amount": "10000000000000",
        "gameToken": {
          "game": "Dice",
          "token": {
            "id": "0x0000000000000000000000000000000000000000"
          }
        }
      },
      {
        "amount": "10000000000000",
        "gameToken": {
          "game": "Dice",
          "token": {
            "id": "0x0000000000000000000000000000000000000000"
          }
        }
      }
    ]
  }
```

### Volume

```graphql
{
  gameTokens(
    where: { user: null, token: "0x0000000000000000000000000000000000000000" }
    first: 3
  ) {
    amount
    game
    id
    dayData(first: 3) {
      date
      amount
    }
  }
}
```

### Returned

```graphql
{
  "data": {
    "gameTokens": [
      {
        "amount": "375982372104615944811976",
        "game": "CoinToss",
        "id": "CoinToss-0x0000000000000000000000000000000000000000",
        "dayData": [
          {
            "date": 1645920000,
            "amount": "1000000000000000000"
          },
          {
            "date": 1646006400,
            "amount": "2000000000000000000"
          },
          {
            "date": 1646092800,
            "amount": "9333463096039600000"
          }
        ]
      },
      {
        "amount": "443111567464828515183796",
        "game": "Dice",
        "id": "Dice-0x0000000000000000000000000000000000000000",
        "dayData": [
          {
            "date": 1645920000,
            "amount": "2000000000000000000"
          },
          {
            "date": 1646006400,
            "amount": "3129709091531314000"
          },
          {
            "date": 1646092800,
            "amount": "19072401025604261600"
          }
        ]
      },
      {
        "amount": "181164494420815950421128",
        "game": "Roulette",
        "id": "Roulette-0x0000000000000000000000000000000000000000",
        "dayData": [
          {
            "date": 1658880000,
            "amount": "23501400000000000000"
          },
          {
            "date": 1658966400,
            "amount": "164000000000000000000"
          },
          {
            "date": 1659052800,
            "amount": "616076223703497772000"
          }
        ]
      }
    ]
  }
}
```

### Dice bet

```graphql
{
  diceBet(
    id: "78422818121456951770279080977534696100272477095763496381910306450399014385281"
  ) {
    betTxnHash
    rollTxnHash
  }
}
```

### Answers

```graphql
{
  "data": {
    "diceBet": {
      "betTxnHash": "0x97e00a527ca57d934df2c36d1042c3d86518d2483503538fccfc695d4ff8b2fe",
      "rollTxnHash": "0xb67c9afe277931adb1ac875fcd3e95ef1e552f6867a67c66f6ad980dc5c035ae"
    }
  }
}
```

### Coin Toss bet

```graphql
{
  coinTossBet(
    id: "100011374288936411037125873457929050060554594796289779142101474215904264617230"
  ) {
    betTxnHash
    rollTxnHash
  }
}
```

### Answer

```graphql
{
  "data": {
    "coinTossBet": {
      "betTxnHash": "0x367e0988a155105973189ef4fb94ee0644cfe33668f2696fcd1416de13d08585",
      "rollTxnHash": "0x4ba3f1d2d42f38ea085e9dac43cbe97350a6bf9a3d3fe688e40c2e4eeffbe9a0"
    }
  }
}
```
