Following our recent release of our support for BNB Chain, in this article we share a detailed developer guide for the BNB community to use to solve their data indexing needs, including how to migrate from The Graph or use our Managed Service.
SubQuery is an open data indexer that is designed to be flexible, fast and provide universal coverage. Our open indexing tool empowers developers to;
- Build their own API that exposes on-chain data for their dApps in hours
- Index chains incredibly quickly with the assistance of dictionaries (pre-computed indices)
- Take advantage of multithreading and optimisation of the store to reduce costly database writes resulting in faster indexing and faster iterations.
Our experience with customers across all verticals in Ethereum, Polygon, Polkadot, Cosmos, Algorand, NEAR and Avalanche (such as wallets, networks, explorers, NFT, DeFi, scanners, etc.) has helped us build the best Indexer for Developers in web3.
Our BNB support is still in its beta, and while we’ve completed considerable testing to ensure that it’s stable, we have further improvements to massively increase the performance and features. Watch this space!
Why Use SubQuery?
SubQuery also brings some major improvements to existing decentralised indexing solutions, including users of The Graph. For one, SubQuery is far more flexible with the ability to make external API calls or import external libraries from within your mapping functions, and better controls to run your projects in your own infrastructure with automated DOS (denial of service) mitigation controls. Additionally, we have no plans to sunset our managed service.
Both SubQuery and The Graph are designed to index data fast, but analysis shows that the existing beta support from SubQuery is already 1.85x faster for common projects over The Graph (e.g the standard Ethereum Name Service project). This adds up when you’re indexing millions of blocks, and is something to consider when choosing your indexer. SubQuery achieves this by using mulit-threading and optimisation of the store to reduce costly database writes. With faster sync times, developers can iterate faster and deliver features to market quicker.
At SubQuery we have an open-source SDK that is easy to use and lightning quick. It provides you with a standard GraphQL endpoint, or you can just query the postgres database directly. With it you can index a unique set of data from your own smart contracts that allows you to build a superior product that blows your competition out of the water! We give you flexibility to get the data that you need in the shape that works best for you.
Reliability is key, and you need a reliable and scalable platform to host it. SubQuery’s managed service is an industry leading hosting solution for all customers that is serving hundreds of millions of daily requests to the biggest projects in Polkadot and Cosmos. We provide our enterprise level customers with services such as dedicated databases, redundant clusters, intelligent multi-cluster routing, and advanced monitoring and analytics. It will support your application when you are ready and will scale with you. Unlike The Graph, we have no plans to sunset our Managed Service.
And finally, in a few months you’ll be able to completely decentralise your SubQuery infrastructure with the SubQuery Network, the future of Web3 infrastructure. The SubQuery Network will index and service your projects data to the global community in an incentivised and verifiable way. It is designed to support any SubQuery project from any layer-1 network including BNB Smart Chain, so you can take advantage of the scale of the unified SubQuery Network from launch.
Read more about the advantages of SubQuery over other options here.
Getting Started
The best way is to start by following our step by step guide on how to create a real world example. Follow our quick start tutorial to see how to index all deposits and withdraws to MOBOX pools in less than 15 minutes.
If you prefer to dive into the code with a kitchen-sink example, try our starter project which contains a running project with an example of all mapping functions. You’ll need to install a recent version of @subql/cli via npm i -g @subql/cli@latest to access this.
With SubQuery’s BNB Smart Chain integration, there are three types of mapping handlers:
- BlockHandler: All blocks and their hash and height
- TransactionHandler: All transactions and their hash, height, and timestamp
- LogHandler: On each and every log that matches optional filter criteria, access various data from the BSC logs
We’ve updated the SubQuery Documentation to add BNB Smart Chain specific information to the general SubQuery documentation. This includes an excellent migration guide to help you move your projects from a SubGraph to a SubQuery Project.
Migrating From The Graph
When we set out to build SubQuery, we always planned to massively improve on the developer experience of other providers, like The Graph, while ensuring that migrating your project to SubQuery is as easy as possible.
BNB developers can benefit from the superior SubQuery experience, including the open-source SDK, tools, documentation, and developer support that the SubQuery ecosystem provides. Additionally, SubQuery’s BSC implementation has been designed to operate almost identically to existing EVM support from other networks that SubQuery already supports, including Ethereum, Polygon, Avalanche, Flare, Cosmos (Ethermint), and Polkadot (FrontierEVM).
If you are an existing user of The Graph, you can follow the guide here to migrate your project to SubQuery and supercharge your indexing today. The migration from a SubGraph to a SubQuery Project is (by design) easy and quick. It may take you an hour or two to complete the migration, depending on the complexity of your SubGraph.
If you would like to find out more about how SubQuery compares to other popular indexers, read our Indexer Comparison article.
Deploying your Project to SubQuery’s Managed Service
Although you will always be able to run your project in your own infrastructure easily, SubQuery’s Managed Service now supports BNB projects. Some of the biggest projects depend on SubQuery’s enterprise level managed service and now you can too.
You can follow the guide here to publish your BNB SubQuery project to our managed service.
You can update your managed service project as much as you want. We even have a staging deployment slot to allow you to do seamless blue/green upgrades without any downtime. This staging slot can also be used to run a clean instance of SubQuery with a fresh database for complete background reindexing of your project. Customers usually link the staging slot to the staging/development versions of their applications.
Once deployed, you can access your project using the SubQuery Explorer, and make requests directly from your app to the provided GraphQL endpoint. Let us know if you would like us to enable more advanced features like GraphQL subscriptions, more complex queries, and aggregation functions.
SubQuery’s Support for BNB
Today we are sharing the following:
- Advanced Indexing of blocks, transactions, and logs
- An excellent quick start tutorial that takes you through the BNB Smart Chain SubQuery indexer
- Full support for BNB Smart Chain in our enterprise level managed service
- Intuitive documentation in the SubQuery Documentation
- A BNB Smart Chain Dictionary: Pre-computed indices to dramatically reduce indexing time
In the coming weeks you can expect:
- A step by step learning course in the SubQuery Academy
- Full support for BNB in our decentralised SubQuery Network
—
If you have any questions, please reach out to Sean Au or James Bayly or contact our Discord Technical Support
About SubQuery
SubQuery is a blockchain developer toolkit enabling others to build Web3 applications of the future. A SubQuery project is a complete API to organise and query data from layer-1 chains. Currently servicing Ethereum, Polygon, BNB, Polkadot, Algorand, Cosmos, NEAR, Flare and Avalanche projects, this data-as-a-service allows developers to focus on their core use case and front-end, without needing to waste time on building a custom backend for data processing. The SubQuery Network proposes to enable this same scalable and reliable solution, but in a completely decentralised way.
Linktree | Website | Discord | Telegram | Twitter | Matrix | LinkedIn | YouTube