Skip to content

Template for creating custom Goldsky subgraphs on Plume

Notifications You must be signed in to change notification settings

plumenetwork/subgraph-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploy subgraph on Plume-testnet

  1. Clone the repository
git clone https://github.com/plumenetwork/subgraph-template.git
cd subgraph-template
  1. Install dependencies
npm install @graphprotocol/graph-ts 
  1. Add your contract abi to /abi
  2. Add the deployed contract address to your config plume.json file
  3. Customize mapping.ts and schema.graphql
  • mapping.ts: This TypeScript file contains the logic to process blockchain events and map them to entities in your GraphQL schema, enabling the indexing of blockchain data for queries.
  • schema.graphql: Defines the structure of data to be indexed from the blockchain, detailing entities, their fields, and relationships for efficient querying through your subgraph.
    Ref : The Graph for more details
  1. Generate AssemblyScript types for smart contract ABIs and the GraphQL schema, facilitating type-safe development of the subgraph.
graph codegen
  1. Compile the subgraph to WebAssembly
graph build
  1. Deploy subgraph to goldksy
goldsky subgraph deploy nft/1.0.0 --path .
  1. Go the the GraphQl api that you get after running the above command
    Here are some sample queries for the template which can query all holders of a NFT collection
  • Fetch All Accounts With Their Tokens
  accounts {
    id
    tokensOwned
    tokens {
      id
      transferCount
    }
  }
}

Output

  "data": {
    "accounts": [
      {
        "id": "0x372532360b38d56f41b4863fcf4ded163326e70b",
        "tokensOwned": "2",
        "tokens": [
          {
            "id": "1",
            "transferCount": "1"
          },
          {
            "id": "2",
            "transferCount": "1"
          }
        ]
      }
    ]
  }
}
  • Fetch All Accounts and Their Token Count
  accounts {
    id
    tokensOwned
  }
}

Output

  "data": {
    "accounts": [
      {
        "id": "0x372532360b38d56f41b4863fcf4ded163326e70b",
        "tokensOwned": "2"
      }
    ]
  }
}

About

Template for creating custom Goldsky subgraphs on Plume

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published