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
Field | Type | Description |
---|
id | ID! | Unique identifier for the store |
bets | BigInt | Total amount of bets placed in the store |
users | BigInt | Total number of users in the store |
Token
Field | Type | Description |
---|
id | ID! | Unique identifier for the token |
symbol | String! | Symbol of the token |
name | String! | Name of the token |
decimals | Int! | Number of decimal places for the token |
bets | BigInt | Total amount of bets placed with the token |
wonCount | BigInt | Total number of bets won with the token |
users | BigInt | Total number of users who have used the token |
amount | BigInt | Total amount of tokens in circulation |
payout | BigInt | Total amount of tokens paid out in winnings |
dividendAmount | BigInt | Total amount of tokens distributed as dividends |
bankAmount | BigInt | Total amount of tokens held in reserve for payouts |
partnerAmount | BigInt | Total amount of tokens held in reserve for partners |
treasuryAmount | BigInt | Total amount of tokens held in reserve for the treasury |
teamAmount | BigInt | Total amount of tokens held in reserve for the development team |
balancesDayDataLength | BigInt | Length 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
Field | Type | Description |
---|
id | ID! | TOKEN-DAYID |
token | Token! | Token |
date | Int! | Date as timestamp |
balance | BigInt! | Balance of token |
PvPToken
Field | Type | Description |
---|
id | ID! | Address |
symbol | String! | Symbol of the token |
name | String! | Name of the token |
decimals | Int! | Number of decimal places the token uses |
bets | Int! | Number of bets made with the token |
uniqueBets | Int! | Number of unique bets made with the token |
users | Int! | Number of unique users who have used the token |
amount | BigInt! | Total amount of the token used in bets |
payout | BigInt! | Total payout of the token for all bets |
dividendAmount | BigInt! | Total amount of the token allocated for dividends |
treasuryAmount | BigInt! | Total amount of the token allocated for the treasury |
teamAmount | BigInt! | Total amount of the token allocated for the team |
initiatorAmount | BigInt! | Total amount of the token allocated for the initiator |
Dicebet
Field | Type | Description |
---|
id | ID! | Unique identifier for the bet |
user | User! | The user who placed the bet |
gameToken | GameToken! | The token used for the bet |
timestamp | BigInt! | Timestamp of when the bet was placed |
resolved | Boolean! | Whether or not the bet has been resolved |
cap | Int! | Maximum bet amount allowed by the game |
betTxnHash | Bytes | Transaction hash of the transaction that placed the bet |
houseEdge | Int | House edge for the game |
amount | BigInt! | Amount of the bet |
rolled | Int | Number that was rolled in the game |
payout | BigInt! | Payout amount for the bet |
rollTxnHash | Bytes | Transaction hash of the transaction that resolved the bet |
CoinTossBet
Field | Type | Description |
---|
id | ID! | Unique identifier for the bet |
user | User! | The user who placed the bet |
gameToken | GameToken! | The token used for the bet |
timestamp | BigInt! | Timestamp of when the bet was placed |
resolved | Boolean! | Whether or not the bet has been resolved |
face | Boolean! | Whether the user bet on a face or not |
betTxnHash | Bytes | Transaction hash of the transaction that placed the bet |
houseEdge | Int | House edge for the game |
amount | BigInt! | Amount of the bet |
rolled | Boolean! | Whether or not the bet won |
payout | BigInt! | Payout amount for the bet |
rollTxnHash | Bytes | Transaction hash of the transaction that resolved the bet |
RouletteBet
Field | Type | Description |
---|
id | ID! | Unique identifier for the bet |
user | User! | The user who placed the bet |
gameToken | GameToken! | The token used for the bet |
timestamp | BigInt! | Timestamp of when the bet was placed |
resolved | Boolean! | Whether or not the bet has been resolved |
numbers | BigInt! | The numbers the user bet on |
betTxnHash | Bytes | Transaction hash of the transaction that placed the bet |
houseEdge | Int | House edge for the game |
amount | BigInt! | Amount of the bet |
rolled | Int | Number that was rolled in the game |
payout | BigInt! | Payout amount for the bet |
rollTxnHash | Bytes | Transaction hash of the transaction that resolved the bet |
KenoBet
Field | Type | Description |
---|
id | ID! | Unique identifier for the bet |
user | User! | The user who placed the bet |
gameToken | GameToken! | The token used for the bet |
timestamp | BigInt! | Timestamp of when the bet was placed |
resolved | Boolean! | Whether or not the bet has been resolved |
numbers | BigInt! | The numbers the user bet on |
betTxnHash | Bytes | Transaction hash of the transaction that placed the bet |
houseEdge | Int | House edge for the game |
amount | BigInt! | Amount of the bet |
rolled | BigInt! | Number that was rolled in the game |
payout | BigInt! | Payout amount for the bet |
rollTxnHash | Bytes | Transaction hash of the transaction that resolved the bet |
RussianRouletteBet
Field | Type | Description |
---|
id | ID! | Unique identifier for the bet |
user | User! | The user who placed the bet |
gameToken | PvPGameToken! | The token used for the bet |
timestamp | Int! | Timestamp of when the bet was placed |
resolved | Boolean! | Whether or not the bet has been resolved |
canceled | Boolean | Whether or not the bet was canceled |
amount | BigInt! | Amount of the bet |
deathRatio | Int | The ratio of death in the game, if applicable |
startsAt | Int | The start time of the game, if applicable |
maxSeats | Int | The 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 |
pot | BigInt! | Current pot size, if applicable |
gameStartedTxnHash | Bytes | Transaction hash of the transaction that started the game, if any |
houseEdge | Int! | House edge for the game |
payout | BigInt | Payout amount for the bet, if applicable |
killedSeatsNumber | Int | The 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 |
rollTxnHash | Bytes | Transaction hash of the transaction that resolved the bet, if any |
rollTime | Int | Timestamp of when the bet was resolved, if any |
GameToken
Field | Type | Description |
---|
id | ID! | The ID of the game token or game token account |
user | User | The user who created the game token or game token account |
token | Token! | The token used for betting |
game | String! | The name of the game associated with the game token |
houseEdge | Int | The house edge for the game |
bets | BigInt! | The total number of bets placed on the game |
wonCount | BigInt! | The total number of bets won on the game |
users | BigInt! | The total number of users who have placed bets on the game |
amount | BigInt! | The total amount of tokens that have been bet on the game |
payout | BigInt! | The total amount of tokens that have been paid out in winnings |
dayDataLength | BigInt! | The number of days for which data is available for the game |
dayData | [GameTokenDayData!] | Derived from the game token ID. |
GameTokenDayData
Field | Type | Description |
---|
Id | ID! | GAME-TOKEN-DAYIDor GAME-TOKEN-ACCOUNT-DAYID |
gameToken | GameToken! | Token used in game |
date | Int! | Date as timestamp |
bets | BigInt! | The total number of bets placed |
wonCount | BigInt! | Total number of bets won on the game |
users | BigInt! | Total number of users who have placed bets on the game |
amount | BigInt! | Total amount of tokens that have been bet on the game |
payout | BigInt! | Total amount of tokens that have been paid out in winnings |
PvPGameToken
Field | Type | Description |
---|
Id | ID! | The ID of the game token or game token account |
user | User! | The user who created the Game token |
token | PVPToken! | Token used in game |
game | String! | The name of the game associated with the game token |
houseEdge | Int! | House edge for the game |
bets | Int! | The total number of bets placed on the game |
uniqueBets | Int! | Number of unique bets made with the token |
users | Int! | Total number of users who have placed bets on the game |
amount | BigInt! | Total amount of tokens bet on the game |
payout | BigInt! | Total amount of tokens that have been paid out in winnings |
dayDataLength | Int! | Number of days for which data is available for the game |
dayData | [PvPGameTokenDayData!] | Derived from (field: "gameToken") |
PvPGameTokenDayData
Field | Type | Description |
---|
Id | ID! | GAME-TOKEN-DAYID or GAME-TOKEN-ACCOUNT-DAYID |
gameToken | PvPGameToken! | Token used in game |
date | Int! | Date as timestamp |
bets | Int! | The total number of bets placed on the game |
users | Int! | Total number of users who have placed bets on the game |
amount | BigInt! | Total amount of tokens bet on the game |
payout | BigInt! | Total amount of tokens paid out in winnings |
User
Field | Type | Description |
---|
Id | ID! | Account |
firstBetTimestamp | BigInt! | Timestamp of the first bet |
lastBetTimestamp | BigInt! | 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
Field | Type | Description |
---|
Id | ID! | USER-TOKEN |
user | User! | User address |
token | Token! | Token used by the user |
bets | BigInt! | The total number of bets placed by user |
wonCount | BigInt! | Total number of bets won |
amount | BigInt! | Total amount of tokens bet |
payout | BigInt! | Total amount of tokens paid out in winnings |
UserTokenDayData
Field | Type | Description |
---|
Id | ID! | USER-TOKEN-DAYID |
userToken | UserToken! | Token used by user |
date | Int! | Date as timestamp |
bets | BigInt! | The total number of bets placed by user |
wonCount | BigInt! | Total number of bets won |
amount | BigInt! | Total amount of tokens bet |
payout | BigInt! | Total amount of tokens paid out in winnings |
UserOverchargedVRFCost
Field | Type | Description |
---|
Id | ID! | USER-GAME |
user | User! | User address |
game | String! | The name of the game |
amount | BigInt! | Total amount of tokens overcharged |
StakingPool
Field | Type | Description |
---|
Id | ID! | PID |
dayDataLength | BigInt! | Number of days data is available for the staking pool |
dayData | [StakingPoolDayData!] | derivedFrom(field: "stakingPool") |
StakingPoolDayData
Field | Type | Description |
---|
Id | ID! | PID-DAYID |
date | Int! | Date as timestamp |
stakingPool | StakingPool! | Staking pool |
balance | BigInt! | 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
{
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"
}
}
}