The blockchain explorer is used for visualizing on-chain data, providing a comprehensive view of every block, transaction, and address across different blockchain networks. With its user-friendly interface, a blockchain explorer enables users to access and analyze native and derivative data in a practical and informative way, tailored to the specific needs of each network. From chain data to block data, contract data, token data, and address data, every piece of information comes together to form a seamless and robust data structure, unlocking a world of possibilities for blockchain enthusiasts.
Polkadot Native Browser Functions Well but Comes at Cost of Performance
Polkadot’s native browser is the most influential block explorer within the ecosystem, offering comprehensive functionality for any Substrate-based blockchain network to access and supporting one-click switching between multiple chains, making it a top choice for many projects. However, this extensive functionality sacrifices performance due to bloated interactive data causing high network latency. For regular users, it’s more important for the browser to retrieve transactions, query wallet balances, and display network status quickly rather than being comprehensive. This is analogous to choosing a local convenience store over a distant supermarket when you only need to purchase a bottle of beer.
Substats: Free, Flexible, and Lightweight
As a development team in the Polkadot ecosystem, we tried using third-party browser frameworks. However, for customized functionality, we were asked to pay high development fees and couldn’t develop on top of the framework. So we created Substats, a lightweight and open-source framework for block explorers in the Polkadot ecosystem.
Substats provides lightweight components that reduce network dependence and customizable data display. It also supports building backend and database services to expand data processing capabilities. Substats is small, improving access speed, and includes more display charts based on user habits and developer needs.
Substats optimizes all processes to reduce the workload for developers and improve efficiency. For instance, it supports custom data retrieval and implements data read-write separation through cache queues. Moreover, it supports multiple data retrieval methods, such as full node RPC communication and peer-to-peer (P2P) protocol. Substats also has the following features:
Caching and retrieval of data on-chain
Unlike Polkadot.js App, which directly retrieves a large amount of data from on-chain nodes, Substats caches on-chain data and provides stable and flexible data retrieval services for users, greatly improving retrieval speed and flexibility.
A data processing module
Substats serves as a processing station between the user and the blockchain network by using a data processing module. This module is composed of two layers: a caching layer responsible for retrieving on-chain data and storing it in a local database, and a computing layer that processes the data in the database to create more insightful information for users. This includes historical data statistics and network-wide computing power rankings. The idea is to preprocess data to provide users with a more intuitive and faster experience, rather than displaying the entire complex on-chain data. Substats also enables developers to extend statistical data and charts to further enhance the platform’s functionality.
Modular UI components
Substats has implemented a modular design for each UI component, ensuring that they don’t rely on each other. This means developers can avoid the tedious process of code development and UI design and quickly build a customized browser with visually appealing components.
Lower development costs
Substats requires only a few configuration files to achieve one-click deployment and start-up. These improvements designed for technical details significantly reduce development time and cost.
Open-source and secure
Substats is open-source and does not include backend hosting and operation services. All services are deployed and maintained by the project team, avoiding trust costs.
Implementation Principle of Substats
Node services synchronize block data from the blockchain network. Node services include full nodes, third-party data retrieval, and more.
The data crawling module obtains block data from the blockchain node. Substats supports different types of node services such as full nodes, P2P nodes, and local databases, as well as custom data retrieval interfaces.
The data retrieved from the node service is written into a buffer pipeline to segregate the crawling and parsing processes. This buffer pipeline not only facilitates data integrity checks but also provides a robust mechanism for error handling
Take the block data from the buffer pipeline and send it to the parser in an order.
The parser parses the block data and writes it to the database in real-time. The parsing process is accelerated through concurrency.
For general block data, Substats provides available database table structures for developers to use. However, for customized pallet data, developers need to define relevant table structures.
Front-end components periodically read relevant data from the database through HTTP APIs to render web pages.
Let’s start building now!
Substats has been designed with a focus on functionality and performance, catering to the needs of ordinary users who value speed and interactive experience. Whether you are just an individual user in the Polkadot ecosystem or a project team searching for a reliable blockchain browser development framework, Substats will be an excellent tool. For more information, please visit https://github.com/CESSProject/substats/blob/master/README.md.