Combining Offchain and Onchain Data in Real Time

Space and Time Foundation

The Space and Time Foundation is an independent organization dedicated to the advancement and adoption of Space and Time.

Many blockchain applications eventually need data that does not live onchain. A DeFi protocol tracking collateral ratios needs token prices. An NFT marketplace calculating royalties needs metadata stored on IPFS or centralized servers. A compliance system monitoring wallet activity needs to match addresses against offchain identity registries. The question is not whether such apps need to combine onchain and offchain data, but how they can do it without breaking the trust model that defines blockchain applications.

The Challenge of Joining Two Worlds

Onchain data has a very specific set of properties: it is publicly verifiable, immutable once confirmed, and stored in a structured but narrow format. Every EVM transaction produces logs, events, and state changes that can be indexed. Offchain data, by contrast, comes in virtually any format, lives in traditional databases or APIs, and carries no inherent cryptographic guarantee of integrity.

Most teams today bridge this gap using ad hoc solutions. They run custom indexing pipelines that pull onchain events into a traditional database, combine them with offchain data sources, and serve the results through an API. This works for dashboards and analytics, but it does not work for smart contracts. A smart contract cannot call your REST API. And even if it could, it would have no way to verify that the data returned is accurate and not tampered with.

A more sophisticated approach uses oracles to deliver offchain data onchain. However, oracles are designed for standardized data feeds, not for arbitrary queries that join onchain and offchain datasets. If you need to compute the average trading volume of a token across three chains and compare it against an offchain benchmark, no oracle will do that for you out of the box.

What Real-Time Data Joining Actually Requires

To combine onchain and offchain data in real time and in a way that is useful for smart contracts, you need three things: first, a unified data store that can ingest both onchain events and offchain datasets into a single queryable environment; second, a query language expressive enough to handle joins, aggregations, and filtering across these non-uniform sources; and third, a verification mechanism that proves the query result is correct and the underlying data has not been tampered with.

SQL is the natural choice for the query layer; it is the most widely understood data processing language, it handles joins and aggregations natively, and it has decades of optimization behind it. The challenge is therefore not SQL itself but rather creating a SQL execution environment that operates over both onchain and offchain tables with cryptographic integrity.

How Space and Time Makes This Work

Space and Time addresses this by operating as a decentralized data warehouse that natively supports both onchain and offchain data. On the onchain side, SXT indexers collect data from major blockchains starting from the genesis block, storing entire chain histories in queryable, relational tables. These histories are continuously updated in real time as new blocks are produced.

On the offchain side, developers and enterprises can insert their own datasets into SXT, such as market data, real-world asset information, DePIN sensor data, insurance telemetry, or application-level user activity. These offchain tables are secured by the same validator network that secures onchain data. Validators reach BFT consensus on cryptographic commitments for every table, whether the source is (for example) Ethereum event logs or a proprietary enterprise dataset.

This means a developer can write a single SQL query that joins an Ethereum transaction history table with an offchain price feed table or a user activity table, and the result will be backed by a ZK proof generated by Proof of SQL. The proof attests both that the SQL computation was performed correctly and that the underlying data tables have not been manipulated. This result can then be delivered directly to a smart contract for onchain consumption.

Examples of Practical Use Cases

Dynamic Lending Rates: A lending protocol could compute borrower risk scores by joining onchain borrowing history across multiple chains with offchain credit data or institutional reputation scores. The result, proven by Proof of SQL, could feed directly into the smart contract to set personalized interest rates.

RWA Tokenization: Real-world asset protocols need to verify that offchain assets (real estate valuations, bond yields, commodity prices) align with onchain token representations. A SQL query joining onchain token supply tables with offchain asset valuation tables, backed by a ZK proof, provides the verification layer these protocols need.

Compliance and Monitoring: DeFi protocols operating under regulatory requirements can match onchain wallet activity against offchain watchlists or KYC registries, with the query result cryptographically proven so that compliance records carry verifiable integrity.

AI and Blockchain: AI models that make decisions affecting onchain systems need trustworthy inputs. By querying both onchain and offchain data through SXT and verifying the result with Proof of SQL, AI agents can operate on data that is provably accurate.

Why Verification Changes Everything

The ability to join onchain and offchain data has existed in centralized analytics platforms for years. What has not existed is the ability to do it in a way that a smart contract can trust. Without verification, any data pipeline feeding a smart contract is a potential point of manipulation. With ZK-proven query results, a smart contract can verify, onchain and in real time, that the data it is acting on has not been tampered with and that the computation over that data was performed correctly.

This is the fundamental shift. It moves us from a model in which smart contracts are limited to whatever data is natively available on their own chain to a model where they can access any dataset, onchain or offchain, across any chain, and act on verified results. For developers building data-intensive applications, this is the infrastructure that makes previously impossible designs practical. 

Get in touch with us here to start building together.

Space and Time Foundation

The Space and Time Foundation is an independent organization dedicated to the advancement and adoption of Space and Time.