Subgraph

Introduction

The Graph (opens in a new tab) is a decentralized protocol that indexes and queries blockchain data, supporting networks like BASE, Optimism, Ethereum, and IPFS. The BASED.DOMAINS Subgraph simplifies access to domain data, enabling efficient queries about ownership, transfers, records, and more. This eliminates the need for complex direct blockchain interactions, making it easier for developers to build applications that integrate BASED.DOMAINS.

Querying the Subgraph

Using the GraphiQL Interface

  1. Navigate to The Graph's GraphiQL interface (opens in a new tab).
  2. In the left-hand query pane, write or paste your GraphQL query.
  3. Press the "Play" button to execute the query and observe the results in the right-hand pane.

Programmatically in Code

Subgraph Studio API
https://api.studio.thegraph.com/query/63587/based-domains/version/latest (opens in a new tab)

To query the subgraph programmatically, you can use GraphQL client libraries like Apollo (opens in a new tab) or urql (opens in a new tab). Here's a sample JavaScript code snippet using Apollo Client:

import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
 
const client = new ApolloClient({
  uri: 'https://api.studio.thegraph.com/query/63587/based-domains/version/latest',
  cache: new InMemoryCache()
});
 
client.query({
  query: gql`
    {
      slds(first: 5) {
        id
        owner {
          id
        }
        fullName
        registrationTimestamp
        resolver {
          textRecords {
            key
            value
          }
          addresses {
            address
            cointype
          }
        }
      }
    }
  `
}).then(data => console.log(data))
  .catch(error => console.error(error));