An SDK to help users interact with the Space and Time (SxT) TestNet and execute Proof of SQL queries.
The Space and Time Proof of SQL SDK is a Rust crate designed to simplify the process of running SQL queries against the Space and Time TestNet and verifying the results using cryptographic proofs. It leverages the Proof of SQL framework to ensure the integrity and correctness of query results.
Make sure you have the following installed:
- protoc
- OpenSSL
On Debian-based Linux distros you can do the following to install all of them
apt update && apt upgrade -y
apt install -y protobuf-compiler pkg-config libssl-devAdd the following to your Cargo.toml:
[dependencies]
sxt-proof-of-sql-sdk = "0.1.0"Then, run:
cargo buildTo use the CLI:
cargo run --bin proof-of-sql-cli -- -q "select * from ethereum.blocks" --sxt-api-key "your_sxt_api_key"Alternatively you may set your SxT API key via the environment variable SXT_API_KEY.
For more options, you can view the help text with:
cargo run --bin proof-of-sql-cli -- --helpTo use the SXT PoSQL Plan Producer:
cargo run --example produce-plan -- -q "select * from ethereum.blocks" --sxt-api-key "your_sxt_api_key"Alternatively you may set your SxT API key via the environment variable SXT_API_KEY.
For more options, you can view the help text with:
cargo run --example produce-plan -- --helpTo run the provided example that counts entries in the Ethereum core tables:
cargo run --example count-ethereum-core --sxt-api-key "your_sxt_api_key"Alternatively you may set your SxT API key via the environment variable SXT_API_KEY.
For more options, you can view the help text with:
cargo run --example count-ethereum-core -- --helpHere's how you can use the SxTClient in your Rust application:
use sxt_proof_of_sql_sdk::native::SxTClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize the SxT client with necessary URLs and API key
let client = SxTClient::new(
"https://api.makeinfinite.dev".to_string(),
"https://proxy.api.makeinfinite.dev".to_string(),
"https://rpc.testnet.sxt.network".to_string(),
"your_sxt_api_key".to_string(),
"path/to/verifier_setups/dynamic_dory.bin".to_string(),
);
// Execute and verify a SQL query
let result = client
.query_and_verify("SELECT COUNT(*) FROM ethereum.transactions", "ethereum.transactions")
.await?;
println!("Query Result: {:?}", result);
Ok(())
}Note: Replace "your_sxt_api_key" with your actual SxT API key, and ensure the verifier setup binary file is correctly specified. For example for Dynamic Dory you can use the file here or fetch the files here.
See deno and node in this repo for examples of JavaScript support.
To obtain an API key for accessing SxT services, please refer to the Space and Time docs.
This project is licensed under the terms of the Cryptographic Open Software License 1.0.