POD SDK
This repository contains the Software Development Kit for the pod Network. It provides a simplified interface for interacting with the POD network.
Features
- Simple connection to POD nodes using WebSocket or HTTP
- Transaction creation and submission
- Receipt verification
- Event subscription and verification
- Committee-based consensus verification
Repository Structure
The POD ecosystem is divided into several repositories:
- POD SDK (this repository): Client-side tools for interacting with the POD network
- POD Types: The main implementation of the POD validator types
- POD Contracts: Smart contracts powering the POD ecosystem
Key Types
The SDK provides several key types:
PodProvider
: The main entry point for interacting with the POD network
PodProviderBuilder
: A builder pattern for creating configured providers
Hash
: A cryptographic hash representing transaction IDs or other hashed data
Receipt
: A proof of transaction inclusion in the blockchain
Committee
: The current set of validators for the network
VerifiableLog
: A log entry that can be cryptographically verified
Usage
use pod_sdk::{PodProvider, PodProviderBuilder};
use alloy_network::EthereumWallet;
use alloy::consensus::TxLegacy;
#[tokio::main]
async fn main() -> Result<()> {
let wallet = EthereumWallet::new(PrivateKeySigner::random());
let ws_url = "ws://127.0.0.1:8546".parse()?;
let provider = PodProviderBuilder::new()
.wallet(wallet)
.on_ws(ws_url)
.await?;
let tx = TxLegacy {
};
let tx_hash = provider.send_transaction(tx).await?;
println!("Transaction sent with hash: {tx_hash}");
let committee = provider.get_committee().await?;
let receipts = provider.get_confirmed_receipts(start_time, None).await?;
for receipt in receipts.items {
if receipt.verify(&committee).unwrap() {
println!("Receipt verified: {:?}", receipt);
}
}
let filter = Filter::new()
.address(contract_address)
.event_signature(event_signature);
let sub = provider.subscribe_verifiable_logs(&filter).await?;
let mut stream = sub.into_stream();
while let Some(log) = stream.next().await {
if log.verify(&committee).unwrap() {
println!("Verified event: {:?}", log);
println!("Proof: {:?}", log.generate_multi_proof());
}
}
Ok(())
}
Installation
Add the following to your Cargo.toml
:
[dependencies]
pod-sdk = "0.1.0"
Using with Contracts
The SDK works seamlessly with POD contract bindings from the POD Contracts repository:
use pod_sdk::PodProvider;
use pod_contracts::auction::Auction;
async fn interact_with_auction(provider: &PodProvider, auction_address: Address) -> Result<()> {
let auction = Auction::new(auction_address, provider.clone());
let highest_bid = auction.highest_bid().call().await?;
println!("Highest bid: {}", highest_bid);
let tx = auction.bid().value(amount).send().await?;
println!("Bid submitted with hash: {:?}", tx.tx_hash());
let receipt = tx.get_receipt().await?;
println!("Transaction confirmed: {:?}", receipt);
let events = auction.events().bid_submitted().query().await?;
for event in events {
println!("Bid submitted by: {:?}, amount: {}", event.bidder, event.amount);
}
Ok(())
}
⚠️ Warning
This is a pre-release version under active development. APIs are subject to change without notice and may contain bugs. Not recommended for production use.