402fly-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, Fly402Error> error handling
Quick Start
Add to your Cargo.toml:
[]
= "0.0.1"
Create a Payment Request
use 402;
let request = new
.with_description;
// Send to client (typically as HTTP 402 response body)
let json = request.to_json?;
Process a Payment
use 402SolanaPaymentProcessor;
use Keypair;
let processor = new;
let result = processor.create_payment.await?;
println!;
Documentation
For full documentation, visit: https://402fly.github.io/docs
License
MIT License - See LICENSE file for details.
Related Packages
402fly-client- HTTP client with automatic payment handling402fly-rocket- Rocket web framework integration402fly-actix- Actix Web framework integration