Parser series (Part 3): How to Access your Smart Contract data through GraphQL

Unmarshal
4 min readAug 17, 2022

--

By now you would have a fair understanding of the data aggregated by your parser and know how to access it and create dashboards through Metabase.

If you have not already, we encourage you to go through the following blogs

  1. What is Unmarshal Parser?
  2. Parser Series (Part 1): Setting Up your own Indexer Using Unmarshal Parser
  3. Parser series (Part 2): How to access your data through Metabase

The other add-on we provide to our users to access their parser data is GraphQL API.

When building the Unmarshal Parser, we realised that there will be cases where you’d want to access the parser data outside of Metabase. For example, you may wish for real-time analytical data of your smart contract to be displayed on your web application.

Ok, but where do I define the schema for my GraphQL API? Or have you taken care of that too?

Continuing our open source first approach, under the hood Postgraphile powers our GraphQL engine. Postgraphile for those of you who are not familiar is a tool which generates a powerful and performant GraphQL API for a given Postgres schema.

Being a team of developers ourselves, we understand the lifecycle of a software product and how frequently there could be unanticipated changes, especially on the user-facing aspect of the product.

Tools like The Graph require the subgraph developer to make all of the GraphQL schema-related decisions upfront compromising on flexibility. If a developer wants to update the schema, they would have to come out with a newer version of the subgraph which again would take its own time to develop and get in sync.

Contrary to the other such tools available to access your smart contract data, Unmarshal Parser focuses on ease of use for developers, and reduction in development time, all while remaining as flexible as possible.

Sounds great, how do I get started?

Enabling GraphQL for your data is simple, just

  1. Head over to the parser section on your console.
  2. Click on the Graph QL: Add new+ button under the add-ons section.
Fig 1.1 Parser homepage highlighting the Add New button

**It is important to note that the GraphQL API is associated with Postgres schemas. Hence, each of the Postgres schemas where your data has been written has its own entry point.

Once ready, your parser homepage should look like this,

Fig 1.2 Highlighted view details button once GraphQL is ready
Fig 1.3 GraphQL view details pop-up

As seen in Fig 1.3, for each database schema you get access to two endpoints

  1. The GraphQL API endpoint itself. Which you could use to get data in your production environment
  2. An endpoint to access your GraphQL Playground. The playground section is intended to also serve as the documentation for the available GraphQL API.
Fig 1.4 GraphiQL playground for marsh_erc20_parser

But, what if I want an API which fetches data in a custom format and with custom filters?

We have you covered,

  1. Head over to our Unmarshal Parser GraphQL GitHub.
  2. Raise a new pull request from a GitHub account linked to the email same as the Unmarshal Console user and mention, the parser id along with the query to fetch your data.
  3. Once verified for correctness and efficiency, we would merge the pull request and you would have access to the new API.

For any queries on using the Parser, reach out to us at support@unmarshal.io. We also have a dedicated developer hive on Discord. Just drop us a message in the “Parser Support” channel and we’ll get back to you.

About Unmarshal

Unmarshal is a Multi-chain Web 3.0 data network aiming to deliver granular, reliable & real-time data to dApps, DeFi protocols, NFTs, Metaverse and GameFi solutions. Unmarshal provides the easiest way to query Blockchain data from Ethereum, Polygon, BNB Chain, Avalanche, Fantom, Celo, Solana, and XDC Network. Unmarshal network consists of data indexers and transforming tools to power Web 3.0 applications on any chain while providing a latent view of transformed data.

Website|Telegram Chat|Telegram Ann|Twitter|Medium|Discord

--

--

Unmarshal

The Most Advanced Blockchain Data Infrastructure #⃣ http://xscan.io: MultiChain Explorer http://unmarshal.io/parser: No Code Smart Contract Indexing