import type { CreateInvoiceOpts, PaymentInvoice, PaymentRail, SendPaymentOpts, VerifyTransactionResult } from '../types.js'; import { type X402Network, type X402PaymentPayload, type X402PaymentRequirements, type X402Scheme, type X402SettleRequest, type X402SettleResponse, type X402SubmitOutcome, type X402VerifyRequest, type X402VerifyResponse } from './types.js'; /** Caller wraps the facilitator HTTP /verify call. */ export type FacilitatorVerify = (req: X402VerifyRequest) => Promise; /** Caller wraps the facilitator HTTP /settle call. */ export type FacilitatorSettle = (req: X402SettleRequest) => Promise; export interface X402RailConfig { /** Recipient wallet address used as PaymentRequirements.payTo. */ payTo: string; /** Token contract address (USDC by default). */ asset: string; /** Network identifier per x402 v1. */ network: X402Network; /** Default scheme. Currently only 'exact' is widely deployed. */ scheme?: X402Scheme; /** Default protected-resource URL. createInvoice can override per * invoice via opts. */ resource: string; /** Default human-readable description. createInvoice can override. */ description?: string; /** Default maxTimeoutSeconds applied to every invoice unless * the caller-supplied expires_in_seconds overrides it. */ defaultMaxTimeoutSeconds?: number; /** Optional currency code displayed in PaymentInvoice.amount_human * and recorded on PaymentReceipt.currency. Defaults to 'USDC'. */ currency?: string; /** Decimals on the configured asset; used only to format * amount_human. Defaults to 6 (USDC). The wire-level atomic units * (maxAmountRequired, value) are always integer strings. */ assetDecimals?: number; /** Optional rail name override. Defaults to * 'x402-{network}-{currency}'. */ name?: string; /** Optional EIP-712 domain extra (passed through to PaymentRequirements.extra). */ extra?: Record; /** Caller-supplied facilitator /verify implementation. */ facilitatorVerify: FacilitatorVerify; /** Caller-supplied facilitator /settle implementation. */ facilitatorSettle: FacilitatorSettle; } export declare class X402PaymentRail implements PaymentRail { readonly name: string; readonly currency: string; private readonly config; private readonly invoices; /** Tx hash → invoice id, populated on settle. Lets verifyTransaction * resolve a previously-settled invoice from a tx hash. */ private readonly txIndex; private readonly revokedWallets; constructor(config: X402RailConfig); createInvoice(opts: CreateInvoiceOpts): Promise; checkStatus(invoiceId: string): Promise; verifyTransaction(txProof: string, expectedAmountBaseUnits?: string): Promise; revokeWallet(walletId: string): Promise; isWalletRevoked(walletId: string): boolean; /** x402 is a pull protocol from the resource server's perspective: * the server collects payment by serving 402 + requirements, then * settling the client's signed authorization. There is no outbound * send. Callers that try this on x402 are misusing the rail. */ sendPayment(_opts: SendPaymentOpts): Promise; /** * Drive verify-then-settle for a PaymentPayload that arrived on * the resource server (decoded from X-PAYMENT). On success, the * cached invoice flips to 'confirmed' with the on-chain tx hash * recorded; the caller passes outcome.transaction to emitReceipt * as tx_proof. On verification failure, the invoice flips to * 'failed' and outcome.invalidReason carries the facilitator's * reason; caller passes that to emitDenial with denial_reason * 'rail_error'. * * The rail does not sign or emit APS receipts itself — that stays * the caller's responsibility, so the issuer key never leaves the * caller's process. */ submitPayment(invoiceId: string, payload: X402PaymentPayload): Promise; /** Returns the X402PaymentRequirements cached for an invoice. Used * by the resource server to assemble the 402 response body. */ getRequirements(invoiceId: string): X402PaymentRequirements | undefined; } export declare function createX402Rail(config: X402RailConfig): X402PaymentRail; /** Default Coinbase CDP facilitator endpoint. The free public tier * supports verification on the EIP-3009 USDC scheme without an API * key (subject to Coinbase's published rate limits, currently * ~1K tx/mo). For higher throughput or non-USDC assets a CDP API key * is required and the caller should wire authorization headers * inside their FacilitatorVerify / FacilitatorSettle implementations. * The rail accepts any compatible facilitator URL — pin via the * closure, do not embed in the rail. */ export declare const DEFAULT_FACILITATOR_URL = "https://api.cdp.coinbase.com/x402"; /** USDC contract on Base mainnet (eip155:8453). */ export declare const USDC_BASE_MAINNET = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"; /** USDC contract on Base Sepolia. */ export declare const USDC_BASE_SEPOLIA = "0x036CbD53842c5426634e7929541eC2318f3dCF7e"; //# sourceMappingURL=index.d.ts.map