The Carbonable Indexer: Efficient Event Sourcing for Smart Contracts

Introducing a proven approach to indexing domain events for business-heavy smart contracts.

Carbonable.io
3 min readMay 31, 2024

First, let’s make sure we’re on the same page. If you’re not familiar with Starknet or Carbonable, I recommend you read a bit about them before continuing.

At Carbonable, we strongly believe in the power of blockchain and event sourcing. With our new repository, we wanted to demonstrate how blockchain can be used as an event store. The result is a combination of web2 and web3 applications that emphasize core business logic, leveraging Cairo for fast and decoupled services.

Overall, our goal was to provide a public infrastructure that allows users to easily build blockchain-backed applications.

Blockchains are decentralized, transparent, traceable, and verifiable. Importantly, they are append-only, which provides unparalleled reliability. With the indexer, we also offer a scalable, distributed event store for free (not including infrastructure and DevOps costs).

Still not convinced? With Cairo, an execution-provable language, we can prove the execution of your core business logic. This stack allows you to build traceable, auditable, transparent, and provable domain logic, ensuring that your systems are trustworthy and reliable.

But wait, aren’t we missing something? What about the outside world? Traditional email? Instant display or UX on the Web? How do we glue it all together? That’s what our indexer is for — to connect the pieces of this complex infrastructure puzzle.

Indexing Starknet

While there are existing indexing solutions for Starknet, they are limited in their use cases. Our team at Carbonable often found ourselves redoing the work every time we built a new app or deployed a new smart contract. So we started building a solution to fill this gap.

That’s why we’re proud to introduce our indexer for blockchain-enabled event sourcing.

The most important information from your smart contracts is the events, and we’ve designed a way to retrieve those events, populated with all the data they encapsulate, in a way that can be universally understood and shared across your applications.

Architecture

We wanted our indexer to be scalable, distributed, and asynchronous, so we decided to use message dispatching as its backbone. We chose nats.io because it is cloud-native, simple, and written in Golang, the language on which we built our indexer. Our rationale was based on its ease of use, speed, and simplicity and the decision allows us to quickly iterate and add value to the Starknet ecosystem.

Here’s how it works in detail:

  • Synchronization: This is the cornerstone of our indexer. We fetch block states, transactions, and events and move them to storage for later use.
  • Configuration: Managing our indexing configuration is critical. We wanted no overhead, so each configuration preserves what has been indexed, allowing for quick re-indexing when an application uses the same configuration.
  • Indexing: The indexer processes and adds value to contract events. While this is only the first version, we foresee significant improvements in the future. The real value lies in our ability to aggregate event keys and values and create mechanisms to add metadata to these events.

What’s Next?

We have already started working with ecosystem products like Nori and Juno and have plans to integrate additional useful libraries.

Our next steps include moving our entire stack around this indexer to add more value to our events and creating a gateway for developers to use this indexer in their own stack, even with self-hosting options.

Carbonable

Carbonable leverages blockchain technology to empower anyone to fund nature restoration projects and offset their emissions efficiently and without greenwashing.

This article was written by Valdo.

Have a question? Get in touch!

📧 Email: reachout@carbonable.io
🐦 Twitter: https://twitter.com/Carbonable_io
💼 LinkedIn: https://www.linkedin.com/company/79714509
👾 Discord: https://discord.gg/gKcButQnKb

--

--

Carbonable.io
Carbonable.io

Written by Carbonable.io

Nature-based Solutions Portfolio Management reinvented. 🌎 Source, Fund, Drive, and Monitor Provable Ecological Restoration. ✅ Powered by Blockchain Technology

No responses yet