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.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(),
});
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 IDamount
: Nota amounttimestamp
: Nota creation timestampstatus
: Nota statusuri
: Nota URIerc20
: Token information for the nota currencysender
: Sender's Ethereum addressreceiver
: Receiver's Ethereum address
Replace
0x...
with the Ethereum address of the account you want to fetch notas for.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.
Last modified 1mo ago