Castle Crush (Reward Share)
We use The Graph's subgraph to index on-chain events. To obtain the Castle Crush subgraph URL reach out to the reNFT team directly. We shall not explore how to make GraphQL queries to the subgraph here. We will merely point out an important potential "gotcha". By default, the query will return at most
100
items in the return set. The maximum you can get is 1000
. To achieve this, you must add the first: 1000
query variable and value in your query. For example,query Query {
rentings(first: 1000, orderBy: cursor, orderDirection: asc) {
id
cursor
renterAddress
rentDuration
rentedAt
}
}
This is not all, however. If the full set of rentings exceeds
1000
items, we will miss all the other rentings. To remedy this, we must use first
in conjunction with a where clause. For example,query Query {
rentings(first: 1000, orderBy: cursor, orderDirection: asc, where: {cursor_gt: 1000}) {
id
renterAddress
rentDuration
rentedAt
}
}
The above query will now pull the next
1000
items. Note that if there are more than 2000
items we are still in trouble. To pull the next 1000
you would use first: 1000, where: {cursor_gt: 2000}.
PLEASE USE THIS TECHNIQUE ON EVERY QUERY YOU ARE MAKING TO THE SUBGRAPH (lendings, rentings, users).