Use Cases

Verifiable Off-Chain Compute for Smart Contracts

Space and Time is giving smart contracts a query language.

Scott Dykstra

Co-Founder, CTO

Last week, Space and Time announced the beta release of our decentralized data warehouse and dapp developer platform. It was a thrilling experiment to work with a world-class team taking our product from inception to launch. We created Space and Time because we believe that, when adopted at scale, blockchain technology has the potential to transform every industry in the world. But we also recognized a critical gap in that potential: the lack of scalable, interoperable, enterprise-compatible infrastructure.

This problem is all the more glaring when you consider the current state of smart contracts. Smart contracts, which are simply business logic written in code that write a row of data to the blockchain containing a transaction, allow business processes to be automated in a trustless way. But today, smart contracts have access to very little storage and compute, and are therefore far too limited to be used as tools for business automation at scale. If we want to see smart contracts adopted by the Fortune 500 enterprise, we have to find a way to make them smarter.

The problem with blockchain storage

A blockchain is an immutable ledger that functions essentially like a massive nested JSON table. The ledger is replicated thousands of times (or tens or hundreds of times in the case of less decentralized L1s) to ensure that it’s tamperproof. The invention of blockchain, I would argue, created the first tamperproof database. 

The problem is that it’s a database of just one table. Even on less decentralized chains, or chains like Sui that are taking a very efficient approach to data storage, there’s not enough storage available for terabytes (or even gigabytes) of data. Since the ledger is replicated tens to thousands of times across the network, it’s completely untenable to store enterprise-scale volumes of data on-chain. Modern business applications are already at terabyte scale, accelerating quickly toward petabyte scale. 

Smart contracts and compute gas

Much like the blockchains they’re deployed on, smart contracts today are inefficient. Just like your data, your smart contract is replicated across the network, which means that each time it’s run, the computation is processed thousands of times. And when you deploy a smart contract on Ethereum, you’re not just paying for storage gas, you’re also paying for compute gas. In order to be truly efficient, smart contracts need a way to run compute off-chain.

Decentralized oracle networks

Decentralized oracle networks, like Chainlink, have revolutionized data for the blockchain by designing a way to write off-chain data to the chain in a tamper-resistant way. With Chainlink, a developer can aggregate data in an off-chain database (like PostgreSQL or MongoDB), or even run scalable analytics in an off-chain data warehouse (like Snowflake or Spark), and connect the result directly back to their smart contract. This allows the contract to execute more complex business logic.

Although the blockchain and the decentralized oracle network aren’t subject to tampering, the centralized database is, effectively breaking the zero-trust model of blockchain. If one company is building indexes for on-chain smart contracts, but they’re aggregating the data in a centralized database, an employee of that company could manipulate the source data and influence the results written to other companies’ smart contracts, which could be completely disastrous for anyone involved with the resulting transactions. Not only do smart contracts need access to a decentralized oracle network to incorporate off-chain data, they also need a way to verify that the data being sent through that oracle network wasn’t tampered at the source.

Zk-proofs

Zk-proofs provide a way to cryptographically guarantee off-chain computation and reduce the amount of data stored on the blockchain. Next-gen zk-rollups, like zkSync Era or Polygon zkEVM, roll up every few thousands of transactions to Ethereum and, essentially, pay Ethereum to handle censorship-resistance and to ensure that data is never lost. 

But provable data is no longer enough, and Web3 is moving toward a requirement of provable compute. If you’re running a derivatives calculation that calculates the volatility of U.S. inflation to enable on-chain predictions markets, how do you know that the calculation was done correctly? It’s one thing to send zk-proofed data through an oracle network to the chain, but for complex use cases like derivatives calculations, you also need a way to guarantee the arbitrary compute on top of the data.

The Space and Time solution

Space and Time is the first tamperproof hybrid database and data warehouse that operates in a decentralized deployment model. Proof of SQL, the novel zk-proof we’ve developed to guarantee SQL operations, allows a developer to run a query in the Space and Time data warehouse and roll up the result to a smart contract on the chain of their choice. Data storage in Space and Time is always free, and while you pay for compute, it’s cheaper than paying for blockchain gas, even on more affordable L2s like Polygon.

Space and Time is not here to replace L1 blockchains, it’s here to enhance them. L1s provide the censorship-resistance layer; Space and Time provides the ability for you to decide what actually needs to be stored in that layer. Your game doesn’t need to store in-game telemetry on-chain, just the final score. A retailer doesn’t need to store all of your browsing history on-chain, just your final purchases. A bank doesn’t need to store every single options calculation on-chain, just the price when someone makes a trade. All of the extra data can be stored in Space and Time, and queried directly from your smart contract when it’s ready for the result.

Proof of SQL is a novel zk-SNARK that cryptographically proves each SQL operation run in Space and Time was done accurately, and that both the query and the underlying data are verifiably tamperproof. We’re giving smart contracts a query language to ask questions about cryptographically guaranteed off-chain data, data on their own chain that we automatically index, and even data on other chains. Space and Time also provides a Tamperproof Python service to enable verifiable computations beyond what you can accomplish with SQL.

Cross-chain messaging isn’t enough, nor is simply connecting off-chain data to the chain. Today, writing data to your smart contract from another chain isn’t really trustless, and writing data from off-chain sources certainly isn’t. Developers need to be able to aggregate on both realtime and historical data, run arbitrary calculations against it, and connect the result back to their smart contract in a verifiable way… a trustless way. That’s where Space and Time comes in.

Essentially, we’re making smart contracts smarter by giving them access to verifiable off-chain compute. With Space and Time, your smart contracts have an efficient storage solution that can process terabytes of granular data and secure the result with novel zk technology. You no longer have to pay expensive gas fees just to secure computation on-chain. Run complex SQL operations in Space and Time that your smart contract can access when needed. When smart contracts have trustless access to a wealth of on-chain and off-chain data at a reasonable price (with extremely high performance and data volume support), they open up a whole new set of use cases that were not previously possible in Web3.

Smart contract use cases with Space and Time

Infrastructure

You can use Space and Time to build other infrastructure, like Web3 auth, tamperproof off-chain compute, analytics, AI/ML, IoT, order books, and other real-world data. Space and Time is your low-latency OLTP and petabyte-scale OLAP database. We handle extremely high streaming volumes with built-in Kafka instances and decentralized SQL queries over the data lake. 

Security

Space and Time can connect compliance data, like KYC data or OFAC compliance lists, to your smart contract to ensure that you’re only facilitating safe and compliant trades. Your smart contract can query Space and Time to get the latest data before executing the trade, like a wallet’s risk score.

Social media

You can run analytics against activity in your social media platform in Space and Time and connect the results to your smart contract to pay content creators on-chain. Aggregate and analyze terabytes of social media data, and send only the most important information to your smart contract.

DeFi/Lending

How does a smart contract for a DeFi protocol ask the question, “show me all wallets that have transacted in liquidity pool XYZ and have a balance greater than $1,000?” Space and Time allows smart contracts to ask complex questions about on-chain activity and combine real-world data with on-chain transactions to enable new financial instruments on-chain. With Space and Time, you can combine real-world credit scores with on-chain transactions to create new Web3 credit scores for decentralized lending platforms. 

Options trading

Space and Time lets you run complex trading models with realtime price information and send your smart contract the realtime result, cryptographically guaranteed to be accurate by Proof of SQL. 

TradFi predictions markets

If you want to bet on US dollar inflation or real estate prices on-chain, you can aggregate all of the off-chain telemetry you need into a single index in Space and Time and run tamperproof queries directly from a smart contract to inform your bets on-chain.

CeFi

We’re taking proof of reserves a step further. Space and Time lets you create a fully automated and transparent exchange process for your CEX. You can send anonymous client deposit data to a smart contract to automatically execute a custodial purchase. Don’t just prove that you're doing the right thing. Set up a system where you can't do the wrong thing. 

Custodial digital assets

Don’t let self-custody be a barrier to adoption of your game, exchange, or bank. You can hold custody of your users’ digital assets in Space and Time, a tamperproof database. Your smart contract can then query Space and Time to mint their assets to them when they’re ready to take custody.

Gaming

Your Web3 game smart contract needs access to all the metadata associated with how and why a player should be rewarded on-chain. Your gaming servers can stream live gameplay data and secure it in Space and Time. Then when needed, your smart contract can ask questions like, “over the last minute, who won, and what were the scores?” in order to appropriately mint the winners a reward on-chain. 

Insurance

If you want to facilitate parametric insurance on-chain, you need off-chain data. For example, if you’re insuring against hurricane damage in Florida, you need data from weather APIs to know if there was a hurricane. But you can’t just query those APIs every hour, return gigabytes of data about the current weather in Florida, and put that on-chain. Instead, you can store it in Space and Time and have your smart contract query it when needed. Store terabytes of raw, granular data, then aggregate it up to high-level information to put on-chain.

Settlement systems and third party auditing

Banks, CeFi exchanges, and financial institutions need to share private, sensitive third-party information with auditors and with each other. These institutions can write that data into Space and Time as a tamperproof, immutable ledger and delegate access to third parties with cryptographic guarantees that the data hasn't been manipulated.

Loyalty programs

If a credit card company or airline wants to put loyalty rewards on-chain to allow their customers to exchange loyalty points for crypto or NFTs, they need a way to join that loyalty data with information about their customers’ wallets. Space and Time lets them load their loyalty system data from a centralized database into our platform to join it with on-chain data in a familiar SQL format.

Tokenization of real-world assets

If you want to put real-world assets (like tickets, equities, or real estate) on-chain, you need some way to connect all the relevant metadata to the blockchain—and not just live data, but terabytes of historical data as well. You can’t store it directly on-chain, but you can store it in Space and Time and aggregate the most important information to publish on-chain. A smart contract can directly query all of this metadata during a trade execution to get an accurate data point for that moment in time.

The author and Space and Time make no representation or warranty, express or implied, as to the fairness, accuracy, completeness or correctness of this post (this "Post") or any information herein. This Post has been prepared solely for educational and informative purposes and does not constitute an offer to sell, or a recommendation or solicitation of an offer to subscribe for or purchase any securities.

Certain statements contained in this Post may be statements of the author’s or Space and Time’s beliefs, plans and expectations about the future and other forward-looking statements that are based on the author’s current expectations or beliefs as well as a number of assumptions about Space and Time’s operations, future development plans, growth prospects, market conditions, and factors beyond the author’s or Space and Time’s control or third party sources and involve known and unknown risks and uncertainties that could cause actual results to differ materially from those contemplated by the relevant forward-looking statements.

Scott Dykstra

Co-Founder & CTO

Scott Dykstra is Co-Founder and Chief Technology Officer for Space and Time, as well as Strategic Advisor to a number of database and Web3 technology startups including Sotero. Scott has a tenured history of building and scaling large engineering teams around complex greenfield challenges and research-driven development. With a specialization in enterprise-scale analytics, Scott previously served as a VP of Cloud Solutions at Teradata, where he spent nearly eight years bringing Teradata from on-premise deployments to next-gen, cloud-based SaaS. Scott is a visionary product leader, with product development expertise across Web3, data warehousing, cloud, and derivatives trading. Scott obsesses over beautiful UX/UI. An entrepreneur to the core, Space and Time is Scott's second successful endeavor as an executive for a research-driven startup.