/** * @module utils/x402-direct * @description Recognize x402 direct SPL token payments on an agent's ATA * by scanning transaction history and filtering for x402 patterns. * * @category Utils * @since v0.6.4 */ import { type Connection, PublicKey } from "@solana/web3.js"; /** * @interface SettlementPayload * @description Settlement metadata from the merchant's PAYMENT-RESPONSE. * @category Utils * @since v0.6.4 */ export interface SettlementPayload { /** SHA-256 service hash. */ readonly serviceHash: string; /** Resource identifier. */ readonly resource: string; /** Agent wallet (base58). */ readonly agentWallet: string; /** Depositor wallet (base58). */ readonly depositorWallet: string; /** Amount in smallest unit. */ readonly amount: string; /** Service timestamp. */ readonly timestamp: number; } /** * @interface X402DirectPayment * @description A recognized x402 direct SPL transfer on an agent's ATA. * @category Utils * @since v0.6.4 */ export interface X402DirectPayment { /** Transaction signature. */ readonly signature: string; /** Transfer amount (in smallest token unit). */ readonly amount: bigint; /** Source ATA (payer). */ readonly payerAta: PublicKey; /** Destination ATA (payTo / agent). */ readonly payeeAta: PublicKey; /** Token mint used for transfer. */ readonly mint: PublicKey; /** Memo data (if a Memo instruction was included). */ readonly memo: string | null; /** Matched settlement payload (if server-side verification is available). */ readonly settlement: SettlementPayload | null; /** Block time (unix seconds). */ readonly blockTime: number | null; /** Slot number. */ readonly slot: number; } /** * @interface GetX402DirectOptions * @description Options for {@link getX402DirectPayments}. * @category Utils * @since v0.6.4 */ export interface GetX402DirectOptions { /** Max signatures to scan (default: 100). */ readonly limit?: number; /** Only return transfers from this specific payer. */ readonly filterPayer?: PublicKey; /** Known settlements from server-side PAYMENT-RESPONSE logs. * Used for deterministic hash matching. */ readonly knownSettlements?: SettlementPayload[]; /** Only include payments that match x402 memo prefix. Default: false. */ readonly requireMemo?: boolean; /** Scan before this TX signature (pagination). */ readonly before?: string; /** Scan after this TX signature (pagination). */ readonly until?: string; } /** * @name getX402DirectPayments * @description Scan an agent's ATA for x402 direct payments. * * Fetches recent transaction signatures for the given `payTo` ATA, * inspects each transaction for SPL token transfers, and filters * for x402 payment patterns (memo prefix, settlement hash match, etc.). * * @param connection - Solana RPC connection. * @param payToAta - The agent's receiving ATA (e.g. USDC ATA of Syra). * @param opts - Filter and pagination options. * @returns Array of recognized x402 direct payments, newest first. * * @category Utils * @since v0.6.4 * * @example * ```ts * import { getX402DirectPayments, findATA } from "@oobe-protocol-labs/synapse-sap-sdk"; * * const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); * const payToAta = findATA(agentWallet, USDC_MINT); * * const payments = await getX402DirectPayments(connection, payToAta, { * limit: 50, * knownSettlements: savedSettlements, // from your API PAYMENT-RESPONSE logs * }); * * for (const p of payments) { * console.log(`${p.signature}: ${p.amount} from ${p.payerAta.toBase58()}`); * if (p.settlement) { * console.log(` Matched settlement: ${p.settlement.serviceHash}`); * } * } * ``` */ export declare function getX402DirectPayments(connection: Connection, payToAta: PublicKey, opts?: GetX402DirectOptions): Promise; //# sourceMappingURL=x402-direct.d.ts.map