🟢APIs

This section provides comprehensive guidance on setting up, deploying, and using a custom subgraph based on Goldsky. It is designed to simplify querying blockchain data for StoryHunt’s native AMM DEX.

Prerequisites


Before you begin, ensure your system has the following tools installed:

  • Node.js (>=16.x) and Yarn (>=1.22.x)

  • Git

  • The Graph CLI: Install globally with npm install -g @graphprotocol/graph-cli.

Installation Steps


1. Install Goldsky CLI and Log In

  1. Install Goldsky CLI:

    curl https://goldsky.com | sh
  2. Log In via CLI:

    • Create an API Key in your Goldsky project’s Settings.

    • Log in using:

      goldsky login
  3. Verify Installation: Run:

    goldsky

    This should display the available commands.


Set Up Your Subgraph

Clone Repository

Install Dependencies

Create subgraph.yaml

Create a subgraph.yaml file in the root directory with the following:

Customize the File

Replace placeholders like <START_BLOCK> and <FACTORY_CONTRACT_ADDRESS> with your actual contract details.


Define the Schema

In schema.graphql, define entities:


Implement Mappings

Mappings transform events into queryable data. Example for factory.ts:


Generate Code and Build


Deploy to Goldsky


Subgraph initialization complete!

Our subgraph has now been successfully deployed to Goldsky. The wizard provides a summary of the files written locally, the builds and deploys that were performed, and links to the subgraph dashboard and the GraphiQL web interface to query the subgraph data.

circle-info

you can make use of the subgraph queries url to init the wrapper-sdk

Example subgraph queries url/ endpoint :

Testing and Debugging

Additional Resources


By following these steps and examples, you can fully integrate subgraph with the Storyhunt V3 contracts while leveraging Goldsky for efficient querying.