5. Join on-chain and off-chain data
Write a query that joins your data with blockchain data.
This page is part of the Getting Started guide. For the best experience, make sure to follow the guide step-by-step
This is where Space and Time shines—joining your use case-specific data to our indexed blockchain data in a single request.
With Space and Time, joining on-chain and off-chain data is as simple as running a query. In this example, we'll show you how to join data from the
DAPP_USER_WALLETS table we created in Part 3 with some blockchain data using our REST APIs.
How to join on-chain and off-chain data
Before we get started, please open the API Reference page open for the Data Query Language (DQL) API.
This API requires two inputs:
<SCHEMA_NAME>.<TABLE_NAME>- In this case, we'll use:
sqlText: This will be the SQL command (the query) you want to run. In this example, let's say a Web3 game has a list of wallets representing the players in the queue and needs to pull NFT ownership to appropriately match players by equipment load-out (NFTs) for the next round of play:
SELECT * FROM ETHEREUM.NATIVE_WALLET -- on-chain JOIN TOKEN_TYPE -- on-chain ON WALLET.TOKEN_TYPE_ID = TOKEN_TYPE.ID JOIN My_User_Wallets -- off-chain, aka your app data ON WALLET.WALLET_ADDRESS = MY_USER_WALLETS.USER_WALLET_ADDRESS WHERE TYPE IN ('ERC721') -- only NFTs
You joined your data with our indexed blockchain data!
And now you're ready to start using Space and Time for your use case! Soon, we'll be adding instructions for publishing your query results to a smart contract. For now, explore our APIs and start building on Space and Time.
Updated about 20 hours ago