openlibx402-core
Core library for the X402 payment protocol with Solana blockchain integration.
X402 is an open standard that enables autonomous payments for API access using HTTP 402 "Payment Required" status codes and Solana micropayments.
Features
- PaymentRequest Model: Server-to-client payment requirements with expiration and description
- PaymentAuthorization Model: Client-to-server payment proof with on-chain verification
- Solana Integration: Direct blockchain payment processing with SPL token support
- Error Handling: Comprehensive error types for all X402 operations
- Type Safe: Full type safety with Result<T, X402Error> error handling
Quick Start
Add to your Cargo.toml:
[]
= "0.0.1"
Create a Payment Request
use ;
let request = new
.with_description;
// Send to client (typically as HTTP 402 response body)
let json = request.to_json?;
Process a Payment
use SolanaPaymentProcessor;
use Keypair;
let processor = new;
let result = processor.create_payment.await?;
println!;
Documentation
For full documentation, visit: https://openlibx402.github.io/docs
License
MIT License - See LICENSE file for details.
Related Packages
openlibx402-client- HTTP client with automatic payment handlingopenlibx402-rocket- Rocket web framework integrationopenlibx402-actix- Actix Web framework integration