ZK-SQL Technical Architecture
Space and Time is the first trustless database for the EVM, enabling smart contracts to interact with historical, cross-chain, or offchain data as if it were natively accessible onchain.
ZK-SQL Execution from your Smart Contract
Execution of a ZK-proven query from your smart contract is as simple as sending your request along with a small payment to the QueryRouter contract.
In your smart contract, you simply:
- Import the
QueryRouterinterface (and token interfaces needed for payment/approval). - Set the contract addresses for the chain you're on (see below).
- Authorize a small amount of SXT to cover payments (query execution, callback return, onchain verification, etc.).
- Convert your SQL statement into a hex query plan (you can do this in the SxT Chain App (Query Workbench)[https://chain.spaceandtime.io/tools/query-workbench]).
- Set query
versiontokeccak256("latest"):0x5d7c83ff6d08efb2f110018d8b6814a4719a93273a3ea09ced5cfe0d5db1d001
- Send the request to
QueryRouter. - Implement your callback handler so results can be returned to your contract by the router executor.
To see this in action, use the SxT Chain App tutorials and generated contract examples.
Contract Addresses
Space and Time has deployed QueryRouter contracts that act as onchain interfaces for receiving already-ZK-verified SQL results.
QueryRouter Contract Addresses
- Ethereum Mainnet:
0x220a7036a815a1Bd4A7998fb2BCE608581fA2DbB - Base Mainnet:
0x220a7036a815a1Bd4A7998fb2BCE608581fA2DbB
Onchain Verifier Contract Addresses
- Ethereum Mainnet:
0x55780Ba21EdFBbFEb7033a0F2FC5Cf55Cd62ACf9 - Base Mainnet:
0x13b7463a07Aac6Bd483E4329a7F6768Da1A65518
SXT Token Addresses
- Ethereum Mainnet:
0xE6Bfd33F52d82Ccb5b37E16D3dD81f9FFDAbB195 - Base Mainnet:
0xA2c22252cDc8b7cDdEe1B0b2E242818509fCf7b8
Build, Test, and Learn in SxT Chain App
- SxT Chain App: https://chain.spaceandtime.io/
- Query Workbench: https://chain.spaceandtime.io/tools/query-workbench
- Deploy Query Contract tutorial: https://chain.spaceandtime.io/get-started/deploy-query-contract
- Result Decoder: https://chain.spaceandtime.io/tools/result-decoder
Updated 15 days ago