Subgraph

Goldsky is a powerful subgraph provider that allows game developers to efficiently query blockchain data on Xai. By leveraging Goldsky, you can access real-time data for both the testnet and mainnet environments, enabling seamless integration and enhanced functionality for your games.

Why Use Goldsky Subgraphs?

Subgraphs are essential for indexing and querying blockchain data quickly and efficiently. Goldsky provides robust and scalable subgraph solutions, making it easier to interact with complex blockchain data structures. Key benefits include:

  • Real-time Data Access: Obtain up-to-date information from the blockchain, ensuring your game logic remains current and accurate.

  • Efficient Queries: Optimize your data retrieval processes with high-performance querying capabilities.

  • Seamless Integration: Easily integrate subgraph data into your game development workflows.

Accessing Goldsky Subgraphs

Goldsky provides endpoints for both the Xai testnet and mainnet, allowing you to test and deploy your game with reliable data sources.

Testnet Subgraph

To access the Xai testnet subgraph, use the following endpoint:

bashCopy codehttps://api.goldsky.com/api/public/project_cl8ylkiw00krx0hvza0qw17vn/subgraphs/blocks/xai-sepolia/gn

This endpoint provides access to testnet data, enabling you to develop and test your game in a safe environment before deploying to mainnet.

Mainnet Subgraph

For live data on the Xai mainnet, use this endpoint:

bashCopy codehttps://api.goldsky.com/api/public/project_cl8ylkiw00krx0hvza0qw17vn/subgraphs/blocks/xai/gn

This endpoint ensures you can access real-time mainnet data, crucial for deploying your game to production with accurate and reliable information.

How to Use Goldsky Subgraphs

  1. Setup Your Environment: Ensure your development environment is configured to make HTTP requests. Common tools include cURL, Postman, or integrated directly within your codebase using libraries like Axios (JavaScript) or Requests (Python).

  2. Querying Data: Construct your GraphQL queries to fetch the necessary data from the subgraphs. Here is a basic example of a GraphQL query to get block information:

    graphqlCopy code{
      blocks(first: 5) {
        id
        number
        timestamp
      }
    }
  3. Integrating into Your Game: Use the data retrieved from Goldsky subgraphs to enhance your game logic. Whether you need player stats, game state information, or other blockchain-related data, subgraphs provide a reliable source.

  4. Testing: Always test your queries on the testnet first to ensure they return the expected data. Once validated, you can confidently switch to the mainnet endpoint for production.

Additional Resources

For more detailed information and advanced usage, refer to the Goldsky documentation:

By leveraging Goldsky subgraphs, you can build more dynamic, data-driven games on the Xai blockchain, ensuring a smooth and enriched gaming experience for your users.

Last updated