Following our recent release of our support for Optimism, we are pleased to share a detailed developer guide for the Optimism 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 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.
Our experience with customers across all verticals in Ethereum, Polygon, BNB Smart Chain, 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.
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 supported network including Optimism, 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 using a real world example project. Follow our quick start tutorial to see how to index all claim events from the Optimism airdrop contract in less than 15 minutes.
If you prefer to dive into the code with a kitchen-sink example, try our starter projects forOptimism 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 Optimism 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 Optimism logs
We’ve updated the SubQuery Documentation to add Optimism 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.
Optimism 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 Optimism implementation has been designed to operate almost identically to existing EVM support from other networks that SubQuery already supports, including Ethereum, Polygon, BNB Smart Chain, 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 Optimism 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 Optimism 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 Optimism
Today we are sharing the following:
- Advanced Indexing of blocks, transactions, and logs
- Full support for Optimism in our free enterprise level managed service
- Intuitive documentation in the SubQuery Documentation
- A quick start guide for claim events from the Optimism airdrop contact. dividends claimed on the WINR staking contract.
- An Optimism 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 Optimism 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 facilitating the construction of 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, Optimism, Arbitrum, BNB, NEAR, Polkadot, Avalanche, Algorand, Cosmos and Flare projects, this data-as-a-service allows developers to focus on their core use case and front-end without wasting time building a custom backend for data processing activities. In the future, the SubQuery Network intends to replicate this scalable and reliable solution in a completely decentralised manner.
Linktree | Website | Discord | Telegram | Twitter | Matrix | LinkedIn | YouTube