fly402-core

Crates.iofly402-core
lib.rsfly402-core
version0.0.3
created_at2025-11-01 07:28:37.828432+00
updated_at2025-11-01 07:28:37.828432+00
descriptionCore library for the X402 payment protocol with Solana blockchain integration
homepagehttps://github.com/SerPepe/402fly
repositoryhttps://github.com/fly402/fly402
max_upload_size
id1911783
size164,214
(SerPepe)

documentation

README

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:

[dependencies]
402fly-core = "0.0.1"

Create a Payment Request

use 402fly_core::{PaymentRequest, Fly402Config};

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()?;

Process a Payment

use 402fly_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);

Documentation

For full documentation, visit: https://402fly.github.io/docs

License

MIT License - See LICENSE file for details.

Related Packages

Commit count: 0

cargo fmt