🌌 Analytics / API BigData

A transparent protocol

To build a more transparent protocol, we develop several analytics dashboards and tools to let you easily follow all the metrics around the project.

What is The Graph?

The Graph is a decentralized protocol for indexing and querying data from blockchains, starting with Ethereum. It makes it possible to query data that is difficult to query directly.


BetSwirl Subgraph Introduction

BetSwirl has a GraphQL API Endpoint hosted by The Graph called a subgraph for indexing and organizing data from the BetSwirl smart contracts.

Subgraph information is serviced by a decentralized group of server operators called Indexers.

Polygon

BNB Smart Chain

Avalanche

Arbitrum One

Helpful Resources


BetSwirl Entities

Store

FieldTypeDescription
idID!Unique identifier for the store
betsBigIntTotal amount of bets placed in the store
usersBigIntTotal number of users in the store

Token

FieldTypeDescription
idID!Unique identifier for the token
symbolString!Symbol of the token
nameString!Name of the token
decimalsInt!Number of decimal places for the token
betsBigIntTotal amount of bets placed with the token
wonCountBigIntTotal number of bets won with the token
usersBigIntTotal number of users who have used the token
amountBigIntTotal amount of tokens in circulation
payoutBigIntTotal amount of tokens paid out in winnings
dividendAmountBigIntTotal amount of tokens distributed as dividends
bankAmountBigIntTotal amount of tokens held in reserve for payouts
partnerAmountBigIntTotal amount of tokens held in reserve for partners
treasuryAmountBigIntTotal amount of tokens held in reserve for the treasury
teamAmountBigIntTotal amount of tokens held in reserve for the development team
balancesDayDataLengthBigIntLength of the array, which contains historical token balances for each day
balancesDayData[TokenBalancesDayData!]Derived from the token balances day data field
usersTokens[UserToken!]Derived from UserToken field

TokenBalancesDayData

FieldTypeDescription
idID!TOKEN-DAYID
tokenToken!Token
dateInt!Date as timestamp
balanceBigInt!Balance of token

PvPToken

FieldTypeDescription
idID!Address
symbolString!Symbol of the token
nameString!Name of the token
decimalsInt!Number of decimal places the token uses
betsInt!Number of bets made with the token
uniqueBetsInt!Number of unique bets made with the token
usersInt!Number of unique users who have used the token
amountBigInt!Total amount of the token used in bets
payoutBigInt!Total payout of the token for all bets
dividendAmountBigInt!Total amount of the token allocated for dividends
treasuryAmountBigInt!Total amount of the token allocated for the treasury
teamAmountBigInt!Total amount of the token allocated for the team
initiatorAmountBigInt!Total amount of the token allocated for the initiator

Dicebet

FieldTypeDescription
idID!Unique identifier for the bet
userUser!The user who placed the bet
gameTokenGameToken!The token used for the bet
timestampBigInt!Timestamp of when the bet was placed
resolvedBoolean!Whether or not the bet has been resolved
capInt!Maximum bet amount allowed by the game
betTxnHashBytesTransaction hash of the transaction that placed the bet
houseEdgeIntHouse edge for the game
amountBigInt!Amount of the bet
rolledIntNumber that was rolled in the game
payoutBigInt!Payout amount for the bet
rollTxnHashBytesTransaction hash of the transaction that resolved the bet

CoinTossBet

FieldTypeDescription
idID!Unique identifier for the bet
userUser!The user who placed the bet
gameTokenGameToken!The token used for the bet
timestampBigInt!Timestamp of when the bet was placed
resolvedBoolean!Whether or not the bet has been resolved
faceBoolean!Whether the user bet on a face or not
betTxnHashBytesTransaction hash of the transaction that placed the bet
houseEdgeIntHouse edge for the game
amountBigInt!Amount of the bet
rolledBoolean!Whether or not the bet won
payoutBigInt!Payout amount for the bet
rollTxnHashBytesTransaction hash of the transaction that resolved the bet

RouletteBet

FieldTypeDescription
idID!Unique identifier for the bet
userUser!The user who placed the bet
gameTokenGameToken!The token used for the bet
timestampBigInt!Timestamp of when the bet was placed
resolvedBoolean!Whether or not the bet has been resolved
numbersBigInt!The numbers the user bet on
betTxnHashBytesTransaction hash of the transaction that placed the bet
houseEdgeIntHouse edge for the game
amountBigInt!Amount of the bet
rolledIntNumber that was rolled in the game
payoutBigInt!Payout amount for the bet
rollTxnHashBytesTransaction hash of the transaction that resolved the bet

KenoBet

FieldTypeDescription
idID!Unique identifier for the bet
userUser!The user who placed the bet
gameTokenGameToken!The token used for the bet
timestampBigInt!Timestamp of when the bet was placed
resolvedBoolean!Whether or not the bet has been resolved
numbersBigInt!The numbers the user bet on
betTxnHashBytesTransaction hash of the transaction that placed the bet
houseEdgeIntHouse edge for the game
amountBigInt!Amount of the bet
rolledBigInt!Number that was rolled in the game
payoutBigInt!Payout amount for the bet
rollTxnHashBytesTransaction hash of the transaction that resolved the bet

RussianRouletteBet

FieldTypeDescription
idID!Unique identifier for the bet
userUser!The user who placed the bet
gameTokenPvPGameToken!The token used for the bet
timestampInt!Timestamp of when the bet was placed
resolvedBoolean!Whether or not the bet has been resolved
canceledBooleanWhether or not the bet was canceled
amountBigInt!Amount of the bet
deathRatioIntThe ratio of death in the game, if applicable
startsAtIntThe start time of the game, if applicable
maxSeatsIntThe maximum number of seats in the game, if applicable
opponents[Bytes!]!List of opponents' addresses, if applicable
seats[Bytes!]!List of seat holders' addresses, if applicable
joinedTxnHash[Bytes!]!Transaction hash of the transactions that joined the game, if any
potBigInt!Current pot size, if applicable
gameStartedTxnHashBytesTransaction hash of the transaction that started the game, if any
houseEdgeInt!House edge for the game
payoutBigIntPayout amount for the bet, if applicable
killedSeatsNumberIntThe number of seats killed in the game, if applicable
winners[Bytes!]List of winners' addresses, if applicable
winningSeats[Boolean!]List of whether each seat is a winner, if applicable
rollTxnHashBytesTransaction hash of the transaction that resolved the bet, if any
rollTimeIntTimestamp of when the bet was resolved, if any

GameToken

FieldTypeDescription
idID!The ID of the game token or game token account
userUserThe user who created the game token or game token account
tokenToken!The token used for betting
gameString!The name of the game associated with the game token
houseEdgeIntThe house edge for the game
betsBigInt!The total number of bets placed on the game
wonCountBigInt!The total number of bets won on the game
usersBigInt!The total number of users who have placed bets on the game
amountBigInt!The total amount of tokens that have been bet on the game
payoutBigInt!The total amount of tokens that have been paid out in winnings
dayDataLengthBigInt!The number of days for which data is available for the game
dayData[GameTokenDayData!]Derived from the game token ID.

GameTokenDayData

FieldTypeDescription
IdID!GAME-TOKEN-DAYIDorGAME-TOKEN-ACCOUNT-DAYID
gameTokenGameToken!Token used in game
dateInt!Date as timestamp
betsBigInt!The total number of bets placed
wonCountBigInt!Total number of bets won on the game
usersBigInt!Total number of users who have placed bets on the game
amountBigInt!Total amount of tokens that have been bet on the game
payoutBigInt!Total amount of tokens that have been paid out in winnings

PvPGameToken

FieldTypeDescription
IdID!The ID of the game token or game token account
userUser!The user who created the Game token
tokenPVPToken!Token used in game
gameString!The name of the game associated with the game token
houseEdgeInt!House edge for the game
betsInt!The total number of bets placed on the game
uniqueBetsInt!Number of unique bets made with the token
usersInt!Total number of users who have placed bets on the game
amountBigInt!Total amount of tokens bet on the game
payoutBigInt!Total amount of tokens that have been paid out in winnings
dayDataLengthInt!Number of days for which data is available for the game
dayData[PvPGameTokenDayData!]Derived from (field: "gameToken")

PvPGameTokenDayData

FieldTypeDescription
IdID!GAME-TOKEN-DAYID or GAME-TOKEN-ACCOUNT-DAYID
gameTokenPvPGameToken!Token used in game
dateInt!Date as timestamp
betsInt!The total number of bets placed on the game
usersInt!Total number of users who have placed bets on the game
amountBigInt!Total amount of tokens bet on the game
payoutBigInt!Total amount of tokens paid out in winnings

User

FieldTypeDescription
IdID!Account
firstBetTimestampBigInt!Timestamp of the first bet
lastBetTimestampBigInt!Timestamp of the last bet
userTokens[UserToken!]!Derived from (field: "User")
gamesTokens[GameToken!]!Derived from (field: "User")
DiceBets[DiceBet!]!Derived from (field: "User")
CoinTossBets[CoinTossBet!]!Derived from (field: "User")
RouletteBets[RouletteBet!]!Derived from (field: "User")
KenoBets[KenoBet!]!Derived from (field: "User")
RussianRouletteBets[RussianRouletteBet!]Derived from (field: "User")
overchargedVRFCosts[UserOverchargedVRFCost!]Derived from (field: "User")

UserToken

FieldTypeDescription
IdID!USER-TOKEN
userUser!User address
tokenToken!Token used by the user
betsBigInt!The total number of bets placed by user
wonCountBigInt!Total number of bets won
amountBigInt!Total amount of tokens bet
payoutBigInt!Total amount of tokens paid out in winnings

UserTokenDayData

FieldTypeDescription
IdID!USER-TOKEN-DAYID
userTokenUserToken!Token used by user
dateInt!Date as timestamp
betsBigInt!The total number of bets placed by user
wonCountBigInt!Total number of bets won
amountBigInt!Total amount of tokens bet
payoutBigInt!Total amount of tokens paid out in winnings

UserOverchargedVRFCost

FieldTypeDescription
IdID!USER-GAME
userUser!User address
gameString!The name of the game
amountBigInt!Total amount of tokens overcharged

StakingPool

FieldTypeDescription
IdID!PID
dayDataLengthBigInt!Number of days data is available for the staking pool
dayData[StakingPoolDayData!]derivedFrom(field: "stakingPool")

StakingPoolDayData

FieldTypeDescription
IdID!PID-DAYID
dateInt!Date as timestamp
stakingPoolStakingPool!Staking pool
balanceBigInt!Token balance of the pool

Querying BetSwirl

You can build your own queries using a GraphQL Explorer 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

Top 5 Stores and Tokens with Betting and User Information

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

Returns

{
  "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

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

Returns

{
  "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

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

Returns

{
  "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

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

Returns

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

Coin Toss bet

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

Returns

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