Parser series (Part 2): How to access your data through Metabase

Now that you are done with creating your parser, which is actively tracking your data, parsing it, and saving it to a PostgreSQL database, let’s move to the question of how to access the data?

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

  1. What is Unmarshal Parser?

For data access, we provide add-ons to our users. One of these add-ons is Metabase.

Metabase is an open-source tool to help you extract information from your data. You can use Metabase to build out beautiful internal and public dashboards, save and share queries, etc.

Before getting started with Metabase, let’s revisit the structure of your indexed data.

Understanding the structure of your data

In the Parser series (Part 1): Setting up your first Parser, we deployed a parser for the Marsh ERC20 contract, we will continue to use it as an example.

  • When you create your parser you are asked to enter the database name in which your data is to be indexed. The database name corresponds to a schema in Postgres.
Fig. 1.1 Parser form highlighting the database name field
  • Don’t remember the name you gave? The name of the schema where your parser is writing data can be found under the View details section.
Fig 1.2 Parser listing screen view details section
Fig 1.3 Schema name in the parser View details window

As initially mentioned, all of your data tables are saved under this schema.

  • The data of each of the contract events/functions selected for indexing(at the time of parser creation) is saved into corresponding tables.

Table nomenclature

  • All of the table names are in snake case and are postfixed with _events and _methods for event and function tables respectively.

In the above example, we selected the following events and functions for indexing

  1. Events: Approval, Transfer

We can expect to find the following tables in our schema

  1. Event tables: approval_events, transfer_events

Logging in to Metabase

TL;DR

You can find your Metabase credentials under the parser section on the Unmarshal console page. It is important to note that you will only be able to view your Metabase credentials once you have deployed at least one parser.

Detailed steps

  • Click on the View details in the Metabase Add-On
Fig. 1.4 Metabase add-on view details section

Click on the URL available in the Metabase popup window

Fig. 1.5 URL in Metabase View details window
  • Use the above credentials to log into Metabase

Getting used to Metabase

“Great, I can see the Metabase homepage but what does it all mean?” Might be the immediate next question you have if you are not already familiar with Metabase.

In this section, we will be going over the terminology commonly used when working with Metabase. If you are already familiar with Metabase feel free to skip this section.

Metabase is a widely used tool, and has a lot of learning resources online, to help in your analytics.

Terminology

Fig. 1.6 Metabase homepage highlighting sections

Data (1)

Fig. 1.7 Browse data screen within Metabase
  1. This section serves as a GUI client for the data collected for your indexers.
Fig 1.8 Schemas available in your data source
Fig 1.9 Table structure within the marsh_erc20_parser schema

Questions and SQL (2)

  1. More often than not, you would want to curate specific information from the data tables.

Card (3)

  1. A card symbolises a saved question or SQL query along with its visualisation settings.

Dashboard (4)

  1. A dashboard is a single page within which multiple cards can be embedded into.

Collection (5)

  1. This is a grouping feature in Metabase that lets the users aggregate data based on logical affinity.

Querying your data through SQL

Metabase makes it easy for you to curate data using the Question query builder. But un-avoidably there would be cases where you have to write your SQL queries.

This is not intended on being a guide on writing PostgreSQL queries, there is an abundance of that available online. Here, using an example we want to highlight the schema and table relationship to help you along the way.

Let’s suppose you are looking for an answer to the following question,

Question: Get me the total number of transfers made on the marsh smart contract along with the volume in $MARSH between 2022–02–07 and 2022–02–08

Fig. 1.10 SQL query editor on Metabase

Query

​​SELECT count(id) transfer_count,sum(value::numeric)/1e18 transfer_volumeFROM marsh_erc20_parser.transfer_eventsWHERE block_timeBETWEEN timestamp ‘2022–02–07’AND timestamp ‘2022–02–08’;

Here is what the query would look like. It is important to note the hierarchy of the data. Since the data for the transfer event is saved within the schema in which the parser is deployed, to access the data a similar hierarchy will have to be used.

Challenge

Here is a challenge for you. For your parser complete the following and tag us on Twitter with #UnmarshalParser, we would pick the best dashboards and make them public to showcase them on Unmarshal Analytics Showcase

  1. Create a collection in your personal collection

Advanced level

By now you should be fairly familiar with Metabase and the structure of your data!

In this section, we will go over a couple of powerful tools that you may feel the need for when building complex dashboards.

Cross schema querying

Sooner than later, you will have requirements where you have to aggregate data from multiple smart contracts e.g. if you have multiple smart contracts powering your DAPP.

As mentioned previously, we index your data in Postgres schemas, and Postgres supports cross-querying across all of your schemas making this a non-issue.

Making dashboards public

Reach out to Unmarshal either on Telegram, Discord or Twitter and we would help you out with this. Once your dashboard has been made public by the Unmarshal team, you would get a link which could be either directly used or embedded in your web application using an IFrame.

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

--

--

Blockchain data indexer and api provider

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store