Skip to main content
The Client SDK provides five methods for querying payment state and history. These read directly from the escrow contract and on-chain event logs.

getPaymentState

Derive the lifecycle state of a payment from the escrow contract (amounts and expiry).
import { PaymentState } from '@x402r/core';

const state = await client.getPaymentState(paymentInfo);

// PaymentState enum:
// 0 = NonExistent  - Payment has never been authorized
// 1 = InEscrow     - Funds locked, capturableAmount > 0
// 2 = Released     - Funds released to receiver, may still be refundable
// 3 = Settled      - No funds in escrow or refundable
// 4 = Expired      - Authorization expired, payer can reclaim
getPaymentState(paymentInfo: PaymentInfo): Promise<PaymentState>

paymentExists

Check whether a payment has been collected by reading the escrow’s hasCollectedPayment flag.
const exists = await client.paymentExists(paymentInfoHash);
if (exists) {
  console.log('Payment found');
}
paymentExists(paymentInfoHash: `0x${string}`): Promise<boolean>

isInEscrow

Check if a payment currently has capturable funds in escrow.
const inEscrow = await client.isInEscrow(paymentInfoHash);
if (inEscrow) {
  console.log('Payment has funds in escrow');
}
isInEscrow(paymentInfoHash: `0x${string}`): Promise<boolean>

getPaymentDetails

Retrieve the full PaymentInfo struct by scanning AuthorizationCreated events for the given hash.
const details = await client.getPaymentDetails(paymentInfoHash);

console.log('Payer:', details.payer);
console.log('Receiver:', details.receiver);
console.log('Amount:', details.maxAmount);
getPaymentDetails(
  paymentInfoHash: `0x${string}`,
  fromBlock?: bigint
): Promise<PaymentInfo>
This method scans event logs. Pass fromBlock to limit the scan range if your RPC limits eth_getLogs responses (Base Sepolia typically caps at 10,000 blocks).

getPayerPayments

List all payments where the connected wallet is the payer, by scanning AuthorizationCreated events.
const payments = await client.getPayerPayments();

for (const { hash, paymentInfo } of payments) {
  console.log(`Payment ${hash}: ${paymentInfo.maxAmount}`);
}
getPayerPayments(
  fromBlock?: bigint
): Promise<Array<{ hash: `0x${string}`; paymentInfo: PaymentInfo }>>
Like getPaymentDetails, this scans event logs. Pass fromBlock to limit the range for large histories.

Next Steps

Refund Operations

Request and manage refunds.

Escrow Management

Freeze payments and query escrow periods.

Client Quickstart

Full setup guide for the Client SDK.

Limitations

Known constraints including event log scanning limits.