Zenders,
Last week we had the pleasure of hosting Francesco the founder of Apibara, on the debut episode of our latest campaign, zkLend’s KYT (Know Your Transaction) Sessions. For those of you who don’t know, Apibara is the fastest platform to build production-grade indexers that connect on-chain data to Web2 services.
What are KYT Sessions?
To give you some context, KYT Sessions are a series of immersive talks and tutorials with a final community challenge that will elevate your transaction tracking skills ahead of our mainnet launch. Community members will dive into the basics of blockchain indexing, master the art of navigating block explorers, and all with with visionary Starknet leaders who’ll guide you through this experience.
KYT Session #1: What is Blockchain Data?
While blockchains ensure data integrity and immutability, this data can be difficult to access and work with. Afterall, blockchains serve many purposes from DeFi to gaming, but all of this information is held in a giant ledger. How then do blockchains cater to the various needs of users and surface the different types of information all in an efficient and synthesised manner?
In this first session with Franceso, Apibara’s Founder, we simplified the high-level structures of blockchain data, explored the key components that help us transform data on chain into legible and usable content, and delved into how Apibara’s indexer infrastructure on Starknet brings these elements together.
Let’s get started with the basics:
Nodes
Nodes play a pivotal role in upholding the blockchain. They manage interactions by accepting valid transactions, verifying data integrity, storing information, and coordinating with other nodes in the network. Accessing blockchain data is achievable through direct node running or solutions like Alchemy and Infura. There are many different types of nodes such as full, light, archival, to name a few, and each one will have its own storage and client requirements. For more details, refer to this page for more information.
Remote Call Procedure (RPC)
A full node carries a significant amount of information on the blockchain but how do we know what to extract? RPCs can be thought of as the bridge that allows us to send and retrieve particular types of information back and forth from blockchain nodes. It’s crucial for fetching real-time blockchain data, enabling protocols like zkLend to run balance queries, send transactions, and block detail retrieval tasks. RPC acts as a vital communication line between nodes and data consumers. In particular, JSON-RPC is a lightweight remote procedure call protocol that is widely known for its ease of use and simplicity. However, other RPCs exist including XML-RPC and gRPC.
Indexers
Last but not least, indexers are specialised tools that closely monitor blockchain events through nodes and RPC, resulting in streamlined and effective queries. These versatile tools handle various aspects such as:
- Data Extraction: Skillfully extract on-chain data using RPC and efficiently store it in a database.
- Data Processing & Organization: Diligently to organise the amassed data, ensuring quick and efficient querying.
- API Interaction: Seamlessly interact with the indexer’s database through APIs, facilitating easy data retrieval.
- Frontend Display: Informatively display data in user-friendly interfaces, making it accessible and understandable for users.
Let’s Bring It All Together
Nodes, Remote Call Procedures (RPCs), and indexers collaborate harmoniously to democratise blockchain data. Nodes maintain the blockchain, RPC eases interaction, and indexers organise and present data in user-friendly formats. These three pillars form the backbone of blockchain data accessibility.
What is Apibara?
We have now covered the basics of blockchain data, but how does Apibara fit into all of this? At its core, Apibara serves as a versatile platform for constructing indexers. This open-source tool seamlessly integrates on-chain data with familiar tools, simplifying the indexer creation process significantly.
A highlight of Apibara’s approach is its Direct Node Access (DNA) protocol. It abstracts out all of the complexity of running your own node, using an RPC and building your own indexer. It helps users efficiently process and filter complete blocks of data from Starknet to ensure users receive only the data that is relevant to their needs.
With Apibara, users possess the power to reshape data to suit their database or service requirements. Through Typescript/Javascript functions, data transformation becomes straightforward. Apibara’s utilisation of the Deno runtime for data transformation adds a touch of magic to each block it streams, streamlining the process.
Flexibility is the name of the game. Developers may leverage their preferred JavaScript library, whether it’s Starknet.js, Viem, Zod, or any other to transform data. The outcome? Data from these functions seamlessly populates your database or finds its way to the desired API destination.
Key Features of Apibara
Seamless Integrations
Apibara simplifies integration with databases and APIs.
- Databases: The syncing of on-chain data becomes a breeze, and concerns about data integrity during chain reorganisations are alleviated through Apibara’s automatic data invalidation feature.
- APIs: Fresh indexer data can trigger API invocations effortlessly. Moreover, crafting notification bots for platforms like Telegram and Discord,
Customization
Of course, for those that prefer to take control of certain parts of their data structure implementation, Apibara provides diverse deployment options.
- Locally: Apibara’s capabilities can be directly accessed from a local environment, alongside DNA and integrations.
- Self-Hosted: If self-hosting is preferred, connect to Starknet/appchain nodes and exercise complete control over each setup.
- Hosted: Alternatively, leave it to Apibara to expertly manage the backend node setup. Access data with an API at your fingertips.
Closing Comments
To conclude, the first session has covered two main parts:
- Indexers, Nodes and RPCs in the blockchain context
- How Apibara’s functionalities reveals its potential to simplify the construction of indexers for Starknet developers.
You can also find the slides to the original deck here.
Stay tuned for KYT Sessions #2: Reading Your zkLend Txns coming this Thursday, August 31, at 1400 UTC on zkLend’s Discord server as we journey deeper into the world of blockchain data.
zkLend Team
About zkLend
zkLend is an L2 money-market protocol built on Starknet, combining zk-rollup scalability, superior transaction speed, and cost-savings with Ethereum’s security. The protocol offers a dual solution: a permissioned and compliance-focused solution for institutional clients, and a permissionless service for DeFi users — all without sacrificing decentralisation.