Smart Contract Indexing

Generate custom tables from your own smart contract events.

We’re excited to announce the release of smart contract indexing: a new feature of our blockchain indexing service that allows you to generate a new custom set of tables in Space and Time from your own smart contract events, by simply providing the contract address.

What it is and why we built it

When you build with Space and Time, you have free access to comprehensive blockchain data that we’ve ZK-indexed from major chains in real time. Compared to other indexing solutions, the approach we take is faster, more mature, scalable, ZK-compatible, and most importantly has the ability to index the entire chain. Because we are running sizable data warehouse clusters (not simply single-server PostgreSQL instances) we can hold tens of terabytes of data per cluster. Ethereum alone generates about 2TB of important data per year, and Ethereum is by far the smallest popular chain by data volume.

Our indexing service provides both chain-level data (i.e. tables like wallets, transactions, contracts, blocks, token transfers, etc.—full chain state from genesis block once indexing is complete for a chain) that’s stored in “core” tables, as well as protocol-specific semantic datasets from protocols like Aave, Uniswap, Opensea, dYdX, or price feeds. But we also understand that sometimes developers need access to data around events emitted by their own smart contracts, and we wanted to abstract away the complexity of having to sort through our core tables to get it. 

Today, we’re excited to announce an addition to the SxT indexing service: smart contract indexing. Now, users can submit a list of smart contracts for indexing, and Space and Time will create a new set of custom tables that contain the events from those specific smart contracts. We write the emitted events into new tables that can then be queried, joined with other indexed data or offchain data, and ZK proven sub-second. This allows devs to create highly customized, efficient, and sophisticated applications that leverage chain-level data, protocol-specific data, offchain data, and data from their own smart contract events in a fast, affordable, and ZK-proven way. 

How it works

Getting your own smart contract events

Indexing your smart contract is as simple as submitting the contract address on the Space and Time Studio

  1. Log into the Studio and navigate to the “Get data from chain” button under the “Smart Contracts” tab on the main menu
  2. Select your contract’s chain and enter the address
  3. Review the tables generated by recent onchain data and submit for indexing

That’s it! We pull the ABI, we automatically generate a table for each smart contract event, and we begin populating them for you automatically. 

How SxT blockchain indexing works

We built a powerful Rust-based indexer that grabs every smart contract event associated with each transaction from each block in a verifiable way. It first polls multiple RPC nodes for each chain and verifies that what it received from each RPC node is consistent. Then the indexer decodes the data via smart contract ABIs we cache locally. Finally, this data is transformed into a relational, easy-to-query form and loaded in the data warehouse—an exact copy of what’s currently onchain. When you submit your smart contract for indexing, the emitted events are separately written to a new table that you define. This entire process happens within block time. 

The indexer service is a single Rust-based binary, so as Space and Time continues to decentralize, we plan to add a light node to it so that multiple indexers (Validators) can redundantly index each chain and send commitments on their indexed data to the Transaction nodes for consensus. This planned architecture is detailed in our whitepaper, but here’s a summary: The Transaction node layer is responsible for BFT consensus. Indexing nodes (called Validators) decode and transform raw blockchain data from RPC and build cryptographic commitments on the data that are used later for ZK-proof verification. Both the commitments and the indexed data are sent to the Transaction nodes which come to consensus given multiple redundant indexing nodes that have indexed each chain.

What it enables

  • Customization and Flexibility: Web3 developers often work with unique smart contracts that generate specific events critical to their application's functionality. Other indexing services don’t always cover these specialized events, limiting the developers' ability to create fully optimized and responsive dapps. Space and Time's expanded indexing service addresses this gap by offering the flexibility to index bespoke events.
  • Scalability: Handling and processing blockchain data in-house can be prohibitively resource-intensive, requiring significant infrastructure and technical expertise. By outsourcing this data indexing to Space and Time, developers can scale their applications more efficiently.
  • Improved Data Accessibility: Accessing and querying blockchain data can be complex and time-consuming. This service simplifies the process, providing structured, queryable tables that make it easier for developers to extract insights and integrate blockchain data into their applications.