LogoLogo
HomeLaunch App
  • Introduction
  • General Info
    • Rental Use Cases
    • Compatible Blockchains
    • Whitelabel Interface
    • Custom Solutions
    • Protocol Composability
    • Protocol Fee
    • Frequently Asked (FAQ)
  • Rental Solutions
    • Collateral-Free
    • Collateralized
  • Developers
    • Integration Guide
    • SDK
      • @renft/sdk@^v6.0.0
        • Interacting with Smart Contracts
        • Collateral-Free Integration Guide
        • Castle Crush (Reward Share)
      • @renft/sdk@v5.0.4
        • Collateral-Free Integration Guide
        • Castle Crush (Reward Share)
    • reNFT Contracts' Addresses
    • Querying reNFT's on-chain data
      • Castle Crush (Reward Share)
  • Video Tutorials
    • Collateral-Free
      • How To Lend
      • How To Rent
    • Castle Crush (Reward Share)
      • How To Lend
      • How To Rent
    • Collateralized
      • How To Lend
      • How To Rent
      • Returning & Defaulting
    • Expired Rentals
  • About reNFT
    • Team
    • Contact
Powered by GitBook
On this page
  1. Developers
  2. Querying reNFT's on-chain data

Castle Crush (Reward Share)

Query On-chain data

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).

PreviousQuerying reNFT's on-chain dataNextCollateral-Free

Last updated 2 years ago