Client
Pay 402-gated APIs from Rust via the MPP client re-exported at solana_pay_kit::mpp — read the challenge, sign a credential, retry.
Unlike the server-only SDKs in some languages, Rust also ships the paying side, via the protocol-layer crate re-exported at solana_pay_kit::mpp. The flow is: read the 402 challenge, sign a credential for it, and replay the request with the credential.
Pay a challenge
use solana_pay_kit::mpp::client::{build_credential_header, parse_challenge};
use solana_pay_kit::mpp::solana_keychain::memory::MemorySigner;
use solana_pay_kit::mpp::solana_rpc_client::rpc_client::RpcClient;// 1. Parse the MPP charge challenge from the 402 `WWW-Authenticate` header.let challenge = parse_challenge(www_authenticate)?;// 2. Sign a payment credential and replay the request with it.let authorization = build_credential_header(signer, rpc, &challenge).await?;let res = reqwest::Client::new() .get("https://api.example.com/quote") .header("Authorization", authorization) .send() .await?;println!("{}", res.text().await?);Auto-pay guardrails
For unattended clients, build_charge_transaction_with_options (and build_credential_header_with_options) add guardrails before signing:
- a spending cap (
max_amount_base_units), - an expected-network pin, and
- a refusal to sign unknown Token-2022 mints unless explicitly opted in.
Or just use the CLI
For most cases the pay CLI is the simplest client — it handles the wallet, signing, and the 402 retry transparently, against any pay-kit server:
pay curl http://127.0.0.1:4567/quotePricing
Price a route in solana-pay-kit — a fixed dollar string or a per-request closure. There is no catalogue type; each route names its own price inline.
Signers
Load the operator key that sponsors network fees and signs upto/batch settlement — local keypairs or remote backends — via Solana Keychain.