Denota SDK
Search
⌃K

Querying Notas With The Graph

Denota Protocol provides a subgraph to query nota data using the Graph Protocol. To access nota data, you can use the getNotasQueryURL() function to get the query URL and a GraphQL library like Apollo Client to perform the queries.

Setup

To get started, set up the Apollo Client in your project:
import { ApolloClient, InMemoryCache, gql } from "@apollo/client";
const client = new ApolloClient({
uri: getNotasQueryURL(),
cache: new InMemoryCache(),
});

Sample Query

Here's a sample query that fetches notas for a given account:
const GET_NOTAS = gql`
query GetNotas($account: ID!) {
account(id: $account) {
cheqs {
id
amount
timestamp
status
uri
erc20 {
id
}
sender {
id
}
receiver {
id
}
}
}
}
`;
async function fetchNotas(account) {
try {
const { data } = await client.query({
query: GET_NOTAS,
variables: { account },
});
console.log(data.account.cheqs);
} catch (error) {
console.error("Error fetching notas:", error);
}
}
fetchNotas("0x..."); // Replace with the Ethereum address of the account
This query retrieves the following data:
  • id: Nota ID
  • amount: Nota amount
  • timestamp: Nota creation timestamp
  • status: Nota status
  • uri: Nota URI
  • erc20: Token information for the nota currency
  • sender: Sender's Ethereum address
  • receiver: Receiver's Ethereum address
Replace 0x... with the Ethereum address of the account you want to fetch notas for.

Exploring the Schema

To explore the full schema and test queries, use the GraphiQL playground at the following URL:
This playground allows you to explore the available types, fields, and relationships in the Denota subgraph and test your queries before integrating them into your application.