| Crates.io | openlibx402-core |
| lib.rs | openlibx402-core |
| version | 0.0.3 |
| created_at | 2025-10-31 14:12:02.454211+00 |
| updated_at | 2025-10-31 14:30:15.213554+00 |
| description | Core library for the X402 payment protocol with Solana blockchain integration |
| homepage | https://openlib.xyz |
| repository | https://github.com/openlibx402/openlibx402 |
| max_upload_size | |
| id | 1910106 |
| size | 164,300 |
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.
Add to your Cargo.toml:
[dependencies]
openlibx402-core = "0.0.1"
use openlibx402_core::{PaymentRequest, X402Config};
let request = PaymentRequest::new(
"0.10", // amount in USDC
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC mint
"7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", // payment address
)
.with_description("Premium API access");
// Send to client (typically as HTTP 402 response body)
let json = request.to_json()?;
use openlibx402_core::SolanaPaymentProcessor;
use solana_sdk::signer::keypair::Keypair;
let processor = SolanaPaymentProcessor::new(
"https://api.devnet.solana.com".to_string(),
None
);
let result = processor.create_payment(&payment_request, &keypair).await?;
println!("Transaction: {}", result);
For full documentation, visit: https://openlibx402.github.io/docs
MIT License - See LICENSE file for details.
openlibx402-client - HTTP client with automatic payment handlingopenlibx402-rocket - Rocket web framework integrationopenlibx402-actix - Actix Web framework integration