Skip to content

XRP Scheme

The XRP scheme uses native XRP on the XRP Ledger (XRPL) with signed XRPL Payment transactions. Unlike EVM and Credits which use EIP-712 signatures, XRP payments require the user to manually sign an XRPL transaction.

Network Parameters

ParameterValue
Networkxrpl-mainnet
CurrencyXRP
AssetXRP
Amount unitdrops (1000000 = 1.0 XRP)
RPC endpointhttps://s1.ripple.com:51234
Ripple epoch offset946684800 seconds (2000-01-01T00:00:00Z)

WARNING

XRP is only supported for x402 V1 (per-transaction approval). V3 mandate-based payments are not available for XRP. The user must manually sign the XRPL Payment transaction — auto-signing is not supported.

402 Response

json
{
  "x402Version": 1,
  "accepts": [
    {
      "scheme": "exact",
      "network": "xrpl-mainnet",
      "maxAmountRequired": "1000000",
      "resource": "/api/endpoint",
      "description": "XRP payment required",
      "payTo": "rRecipientAddress",
      "maxTimeoutSeconds": 60,
      "asset": "XRP",
      "extra": {
        "name": "XRP",
        "version": "1"
      }
    }
  ]
}

X-Payment Payload

json
{
  "x402Version": 1,
  "scheme": "exact",
  "network": "xrpl-mainnet",
  "payload": {
    "txHash": "ABC123...",
    "signedTransaction": "1200002200000000...",
    "account": "rSourceAddress",
    "destination": "rDestinationAddress",
    "amount": "1000000",
    "currency": "XRP"
  }
}

Payload Fields

FieldTypeDescription
txHashstringXRPL transaction hash (computed via xrpl.hashes.hashSignedTx)
signedTransactionstringHex-encoded signed XRPL Payment transaction blob
accountstringSender's XRP classic address
destinationstringRecipient's XRP classic address (must match payTo)
amountstringAmount in drops (positive integer string)
currencystringAlways XRP

Payment Flow

1. Construct XRPL Payment Transaction

The payer constructs a standard XRPL Payment transaction with:

  • TransactionType: Payment
  • Account: payer's XRP classic address
  • Destination: recipient's XRP classic address (from payTo in the 402 response)
  • Amount: payment amount in drops (from maxAmountRequired)

2. Sign Transaction

The payer signs the transaction using their XRPL wallet, producing a hex-encoded signed transaction blob (signedTransaction).

3. Compute Transaction Hash

The transaction hash is derived from the signed blob:

javascript
const txHash = xrpl.hashes.hashSignedTx(signedTransaction);

4. Build X-Payment

The signed transaction and metadata are assembled into the X-Payment payload and base64-encoded as the X-Payment header.

5. Verification

The XRP Facilitator verifies the payment:

  • Decodes the signed blob via xrpl.decode() and extracts transaction fields
  • Validates the cryptographic signature via xrpl.verifySignature()
  • Confirms Destination matches payTo, Amount matches required drops, currency is XRP
  • Cross-checks against the stored payment record

6. Settlement

The facilitator submits the signed transaction to XRPL via RPC:

javascript
callRippleRpc('submit', { tx_blob: signedTransaction, fail_hard: false });
  • tesSUCCESS / ter* → transaction accepted
  • tefMAX_LEDGER → transaction expired
  • Finality is confirmed asynchronously on-chain

Key Differences from EVM/Credits

AspectEVM / CreditsXRP
SigningEIP-712 typed data, auto-signed by wallet APINative XRPL signing, manual by user
SettlementImmediate (Credits) or deferred (EVM)Async — submit then chain parser confirms
Status flowsignedusedsignedpendingused
Mandate supportV1 and V3V1 only
Expired tx handlingValidity windowtefMAX_LEDGER expires record
FacilitatorCredits: internal / EVM: externalInternal (multi-asset facilitator)

Released under the MIT License.