Rust Implementation¶
Welcome to the OpenLibx402 Rust implementation documentation. This section covers all Rust packages, libraries, middleware, and examples for building X402-enabled APIs and clients with type-safe, high-performance code.
Overview¶
The Rust implementation provides:
- Core Library - X402 protocol implementation with models, errors, and Solana payment processing
- Client Library - HTTP client with automatic and explicit payment handling
- Middleware - Integration with popular Rust web frameworks (Rocket, Actix Web)
- Examples - Complete working examples for server and client implementations
Quick Navigation¶
📚 Libraries¶
- Core Library - Payment models, errors, and Solana processor
- Client Library - X402 HTTP client with auto-payment support
🔗 Middleware¶
- Rocket Middleware - Rocket web framework integration
- Actix Web Middleware - Actix Web framework integration
🚀 Examples¶
- Rocket Server - Complete server with multiple pricing tiers
- Actix Web Server - Actix Web server with dynamic pricing
📖 Getting Started¶
🔧 Reference¶
Key Features¶
✨ Type-Safe - Compile-time guarantees with Rust's type system 🤖 Automatic Payments - Clients automatically handle payment flows ⚡ High Performance - Zero-copy, async-first design with Tokio 💰 Micropayments - Support payments as low as $0.001 🔐 Secure - Memory-safe, payment verification, nonce-based replay protection 🌐 Framework Agnostic - Works with Rocket, Actix Web, and custom implementations
Crate Dependencies¶
Installation¶
The X402 Flow¶
Why Rust?¶
Rust is an excellent choice for X402 implementations:
- Safety - Memory safety without garbage collection
- Performance - Zero-cost abstractions and minimal runtime
- Concurrency - Fearless concurrency with async/await
- Reliability - Catch bugs at compile time
- Ecosystem - Rich ecosystem of web frameworks and blockchain tools
Support¶
For issues, questions, or contributions: - GitHub Issues - GitHub Discussions - X402 Protocol - Rust Documentation
Next Steps¶
Start with the Installation guide and choose your path:
- Building a Server? → Server Quick Start
- Building a Client? → Client Quick Start
- Need Details? → API Reference