Page cover image

Query Layer

Behind the scenes, there is an extensive query layer that makes it easier for the front-end to pull the data it needs.

Indexing Service

We leverage Airstack (https://www.airstack.xyz/) to create an aggregated look at the underlying Polygon blockchain.

Just so you know: This API is exposed to anyone who wants to build apps or visuals using the CropXYZ data can pull aggregated on-chain data.

Sample Requests

For the initial launch, we used The Graph so here are a set of sample requests that can be made to The Graph query layer. This is more for demonstrative purposes because this entire logic wil be from Airstack in this relaunch.

Overall Game State

All of the smart contracts report their pause status and contract address.

{
  gameStates(first: 20) {
    id
    address
    isPaused
  }
}

https://thegraph.com/hosted-service/subgraph/cropxyz/cropxyz-metaverse?query=Game%20State

Crops Details

This requests pulls the basic details of all crops as well as the time it takes to grow these crops.

{
  crops {
    elementName
    addressMapping {
      tokenAddress
    }
    plotType {
      name
    }
    growthTimeTable {
      deltaNothingToStart
      deltaStartToEarly
      deltaEarlyToMature
      deltaMatureToExpire
    }
  }
}

https://thegraph.com/hosted-service/subgraph/cropxyz/cropxyz-metaverse?query=Crops

Plots

This request pulls the base details about the plots, also it pulls the planted crop (if one has been planted).

{
    plots(first: 1000, skip: 0) {
      id
      width
      height
      tileArea
      baseSpeed
      baseYield
      countClears
      countHarvests
      countDeathClears
      baseYield
      yieldConfig {
        minYield
        maxYield
      }
      stakedCrop {
        id
        elementName
        addressMapping {
          addressName
          tokenAddress
        }
      }
      plotType {
        id
        name
      }
      amountStaked
      timeStartStaked
      timeReadyDelta
      timeExpiredDelta
    }
}

https://thegraph.com/hosted-service/subgraph/cropxyz/cropxyz-metaverse?query=Plots

Plot Actions

The plot actions are the different plots, harvests and clear actions players take on their plot.

{
  plotActions(first: 1000, skip: 0) {
    id
    timestamp
    blockIndex
    playerAddress
    amount
    actionType
    plot {
      id
    }
    currentCrop {
      elementName
      addressMapping {
        tokenAddress
      }
    }
    newCrop {
      elementName
      addressMapping {
        tokenAddress
      }
    }
  }
}

https://thegraph.com/hosted-service/subgraph/cropxyz/cropxyz-metaverse?query=Plot%20Actions

Transactions

Each transaction is broken up into the seeds or gold flowing "in" to the economic layer and how much gold or seed flows "out" of the economic layer.

{
  transactionFlows(first: 1000, skip: 0) {
    timestamp
    blockIndex
    playerAddress
    isGoldInbound
    flowIn {
      tokenAddress
      tokenAmount
    }
    flowOut {
      tokenAddress
      tokenAmount
    }
  }
}

https://thegraph.com/hosted-service/subgraph/cropxyz/cropxyz-metaverse?query=Game%20State

Last updated