Subgraph
The Graph is the indexing layer of our industry, providing a queryable platform for the vast data produced by blockchain networks. The Graph can be used for querying data in the Superfluid ecosystem and other on-chain data. Experiment with queries using the GraphQL Playground.
Before diving into subgraph queries, familiarize yourself with GraphQL basics: Learn GraphQL
Querying Different Networks
Superfluid Explorer
The Superfluid Explorer is an interactive interface for exploring the Superfluid Protocol and interacting with its Subgraph. It provides an intuitive way to query on-chain data, get contract addresses, and manage your Superfluid finances. The console supports various blockchain networks, allowing you to seamlessly switch between them and access specific data sets. Whether you're analyzing streams, checking balances, or staying up to date with the new deployments. The Superfluid Explorer makes these tasks accessible and straightforward.
Explore Superfluid data across various networks using the Superfluid Explorer. Select a network to start querying:
- Popular
- Other
For other networks, use the Superfluid Explorer:
Superfluid ExplorerSubgraph Networks
You can have the full list of available subgraph endpoints in the Subgraph Endpoints page.
Resources
- Subgraph Queries: Guide on Querying the Graph
- Deploy a Subgraph: Creating a Subgraph
- GraphQL Schema: Superfluid Schema
- Our Subgraph Endpoints: Subgraph Endpoints
Helpful Tips
- All addresses in the subgraph (
id
,underlyingAddress
, etc.) are lowercase. - Convert addresses to lowercase before querying.
Notable Breaking Changes
Significant changes were made in October 2021:
totalSubscriptions
is nowtotalSubscriptionsWithUnits
.Subscriber
entity changed toSubscription
.createdAt
andupdatedAt
fields are nowcreatedAtTimestamp
andupdatedAtTimestamp
.
Schema Overview
The Superfluid Subgraph includes various entities for querying. Think of entities as analogous to database tables. Here's a brief overview:
Event Entities
Event entities correspond to contract events, often with added data. Each event entity is immutable and created once.
- Event ID Format:
eventName-transactionHash-logIndex
. - Naming Convention: For V1, event names end with 'Event'.
Higher Order Level Entities (HOL)
HOL entities represent entities over their lifetime and may be updated.
Account
: Represents any address interacting with Superfluid.Token
: Represents valid SuperTokens.Pool
,PoolMember
,Stream
,StreamPeriod
: Related to Superfluid streams and pools.
Aggregate Entities
Aggregate entities store cumulative data at both account-token and global token levels:
TokenStatistic
: Aggregates data for a single Token type.AccountTokenSnapshot
: Aggregates data on an account's interaction with a token.
Query Examples
Super Token Data Query
{
tokens(first: 100) {
id
symbol
name
underlyingAddress
}
}
Get the pools that a user is a member of
To list all pools that an account is currently a member (insert the ethereum address in the query below):
query MyQuery {
pools(
first: 10
where: {poolMembers_: {account: "YOUR_ADDRESS_HERE", account_: {}}}
) {
totalUnits
totalMembers
flowRate
createdAtBlockNumber
}
}
Get all the pools for a specific token
To list all pools for a token (insert the token address in the query below):
query MyQuery {
pools(where: {token: "YOUR_TOKEN_ADDRESS_HERE"}) {
createdAtBlockNumber
createdAtTimestamp
flowRate
id
totalMembers
totalUnits
admin {
isSuperApp
}
}
}
Get all the pools for a specific pool admin
To list all pools for a pool admin (insert the pool admin address in the query below):
query MyQuery {
pools(first: 10, where: {admin: "YOUR_POOL_ADMIN_ADDRESS_HERE"}) {
totalUnits
totalMembers
flowRate
createdAtBlockNumber
token {
id
isSuperToken
symbol
}
}
}
Explore more queries
Explore more queries using the Superfluid Subgraph Playground.