Blockchain guardrails for AI agents. Validate transactions before execution.
ProofGate validates blockchain transactions before your AI agent executes them. It prevents:
- 🚫 Wallet drains from prompt injection attacks
- 🚫 Infinite approvals to malicious contracts
- 🚫 Excessive spending beyond daily limits
- 🚫 High slippage swaps that lose money
Add to your Cargo.toml:
[dependencies]
proofgate = "0.1"
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }use proofgate::{ProofGate, ValidateRequest};
#[tokio::main]
async fn main() -> Result<(), proofgate::Error> {
// Initialize client
let pg = ProofGate::new("pg_live_xxx")?; // Get from www.proofgate.xyz/dashboard
// Validate before sending
let result = pg.validate(ValidateRequest {
from: "0xYourAgentWallet".to_string(),
to: "0xContractAddress".to_string(),
data: "0xa9059cbb...".to_string(), // Transaction calldata
value: Some("0".to_string()),
guardrail_id: None,
chain_id: None,
}).await?;
if result.safe {
// ✅ Execute the transaction
println!("Transaction approved!");
} else {
// 🚫 Transaction blocked
println!("Blocked: {}", result.reason);
}
Ok(())
}Create a new ProofGate client.
let pg = ProofGate::new("pg_xxx")?;Create with custom configuration:
use proofgate::{ProofGate, ProofGateConfig};
use std::time::Duration;
let pg = ProofGate::with_config(ProofGateConfig {
api_key: "pg_xxx".to_string(),
chain_id: 56, // BSC Mainnet
guardrail_id: Some("xxx".to_string()),
base_url: "https://...".to_string(),
timeout: Duration::from_secs(30),
})?;Validate a transaction:
let result = pg.validate(ValidateRequest {
from: "0xAgent...".to_string(),
to: "0xContract...".to_string(),
data: "0x...".to_string(),
value: Some("0".to_string()),
guardrail_id: None,
chain_id: None,
}).await?;
// ValidateResponse has:
// - validation_id: String
// - result: ValidationResult (Pass, Fail, Pending)
// - reason: String
// - safe: bool
// - checks: Vec<ValidationCheck>
// - authenticated: bool
// - evidence_uri: StringValidate and return error if unsafe:
use proofgate::Error;
match pg.validate_or_throw(request).await {
Ok(result) => {
// Safe to execute
}
Err(Error::ValidationFailed { reason, result }) => {
println!("Blocked: {}", reason);
}
Err(e) => return Err(e),
}Check an agent's trust score:
let agent = pg.check_agent("0x123...").await?;
println!("{} {}/100", agent.tier_emoji, agent.trust_score);
// Output: 🥇 85/100Get evidence for a past validation:
let evidence = pg.get_evidence("val_abc123").await?;
println!("{:?}", evidence.transaction);Guardrails define what your agent can do. Create them at proofgate.xyz/guardrails.
Example guardrail rules:
- Whitelist contracts: Only Uniswap, Aave, Compound
- Max approval: 1,000 USDC per approval
- Max slippage: 1% on swaps
- Daily limit: $10,000 total spending
use proofgate::Error;
match pg.validate(request).await {
Ok(result) => { /* success */ }
Err(Error::MissingApiKey) => { /* No API key */ }
Err(Error::InvalidApiKey) => { /* Key doesn't start with pg_ */ }
Err(Error::ValidationFailed { reason, .. }) => { /* Tx blocked */ }
Err(Error::ApiError { status, message }) => { /* API error */ }
Err(Error::NetworkError(e)) => { /* Network failed */ }
Err(Error::Timeout) => { /* Request timeout */ }
Err(Error::ParseError(e)) => { /* JSON parse failed */ }
}native-tls(default) - Use native TLSrustls- Use rustls for TLS
[dependencies]
proofgate = { version = "0.1", default-features = false, features = ["rustls"] }- Go to proofgate.xyz
- Connect your wallet
- Register your AI agent
- Copy your API key (starts with
pg_)
Free tier: 100 validations/month
- Website: proofgate.xyz
- Documentation: docs.rs/proofgate
- Dashboard: www.proofgate.xyz/dashboard
- GitHub: github.com/ProofGate/proofgate-rs
MIT © 0xCR6