Inspiration

I've been asked several times if I can help artists using Paras identify who their HOLDRs are. Typically the artist wants to show their fans some love and thank them for investing in them. There's no easy way to do that without something like The Graph indexing the contract and keeping track of who holds what.

What it does

The Paras subgraph is a subgraph deployed to The Graph's Hosted Service that unlocks the 400,000 (and counting) entities of data available in the x.paras.near contract. In the short time it's been deployed, and despite not yet being fully indexed (92.2% as of today), it's been used by artists, other projects, and people building dashboards to visualize what is happening on NEAR's most well-known and frequented NFT minting platform - Paras.

How we built it

The Paras subgraph was built using instruction and templates provided by The Graph for NEAR course on Vital Point AI, The Graph docs, and through questions in The Graph Discord.

Challenges we ran into

Several challenges were encountered leading to 3 different versions of the subgraph, each improving on what was built before it. V3 is the submission and is currently the most robust. Those challenges included:

  1. Support for NEAR by The Graph is in beta. All the challenges that come with that were present in terms of stability and inevitable bugs. The Graph team was very helpful in overcoming/fixing obstacles related to The Graph technology.

  2. Not quite valid JSON. The Graph support for NEAR relies on the logs emitted by NEAR contracts. Luckily Paras has adopted the NEP-171 event standard, making the data in the contract available. Unfortunately, the log string was found to not be valid JSON (missing {} around the object). As such, some string manipulation needed to occur to format the object appropriately to subsequently map the data to entities in a more intuitive manner.

  3. Some logs are not quite NEP-171. Not all of the methods in the x.paras.near contract are using the NEP-171 standard. That required some checks be implemented in the mappings to determine what type of log was being emitted to handle them appropriately. Unfortunately, the differing outputs would not be identified until after the indexing failed, necessitating a revision and restart. Ultimately this would delay how much indexing could be completed prior to submission time.

  4. Indexing speed. Unfortunately, it's slow. The subgraph has been deployed for 24+ days and it's still trying to catch up and sync with the mainnet, slowly making progress. That is limiting some of its usefulness in other projects - until all the data is available. But it's coming.

  5. No real knowledge of the contract. Had to monitor and watch what was happening in the NEAR block explorer to find/map all the relevant methods that would ultimately lead to the data we are now making available through the subgraph. We were able to use stats.gallery to get an idea of what methods to look for, but until they showed up and emitted a log and without any easy way of going back in time in the explorer - it was a pretty tedious investigative job.

Accomplishments that we're proud of

Pretty happy that we managed to overcome the initial challenges and map the Paras contract in sufficient detail to make a large amount of useful data available to anyone using the subgraph. It can really help projects and applications using it discover insights in the data and build more performant applications.

What we learned

Given the current limitations with how any useful data is indexed using subgraphs for NEAR (primarily limited to action receipts - function calls and what is emitted in logs), learned an incredible amount about string manipulation, error checking, and perseverance in working to maximize what data could be indexed from the Paras contract. Also learned how to query the data in an application to produce even more useful datasets on the frontend.

What's next for Paras meets The Graph

What's next for the subgraph centers around two things: supporting individuals/teams looking to implement it in their projects and potentially updating some of the entity schemas to incorporate more complex relationships that decrease the amount of work on the frontend needed to make queries return the specific data one is interested in.

Built With

  • assemblyscript
  • near
  • react
  • thegraph
Share this project:

Updates

posted an update

I was working on an upgraded version of the subgraph tonight (v4) and accidentally deployed to the v3 location overwriting the subgraph and restarting the indexing. As such, the 430000+ entities seen in the video aren't there anymore. Took about 25 days to get to that point before - unfortunately, going to be a while before this indexing is done again. Apologies for any inconvenience - believe me, I'm as upset as anyone else might be. Stupid mistake.

Log in or sign up for Devpost to join the conversation.