import { type PublicClient, type WalletClient, type Chain, type Transport, type Account } from 'viem'; import { type SupportedChainName } from '@azeth/common'; import { x402Facilitator } from '@x402/core/facilitator'; import { x402ResourceServer, x402HTTPResourceServer, type FacilitatorClient, type RoutesConfig } from '@x402/core/server'; import type { PaymentPayload, PaymentRequirements, VerifyResponse, SettleResponse, SupportedResponse } from '@x402/core/types'; import { AzethSIWxStorage } from './storage.js'; import { type AgreementTerms } from './extensions/payment-agreement.js'; /** CAIP-2 network identifiers for supported chains */ export declare const CAIP2_NETWORKS: Record; /** Configuration for the x402 stack */ export interface X402StackConfig { /** Chain name */ chainName: SupportedChainName; /** Network in CAIP-2 format */ network: `eip155:${string}`; /** Payment recipient address */ payTo: `0x${string}`; /** Wallet client for gas settlement */ walletClient: WalletClient; /** Public client for on-chain reads */ publicClient: PublicClient; /** Agreement terms (null = agreements disabled) */ agreementTerms?: AgreementTerms | null; } /** The complete x402 V2 stack returned by createX402Stack */ export interface X402Stack { /** Self-hosted facilitator */ facilitator: x402Facilitator; /** Resource server wrapping the facilitator */ server: x402ResourceServer; /** HTTP server wrapping the resource server with routes */ httpServer: x402HTTPResourceServer; /** Agreement-aware SIWx storage */ storage: AzethSIWxStorage; /** Public client for on-chain reads (needed by keeper) */ publicClient: PublicClient; /** Wallet client for gas settlement (needed by keeper) */ walletClient: WalletClient; } /** Wraps x402Facilitator as a FacilitatorClient for in-process use. * Avoids HTTP round-trips by calling the facilitator directly. */ export declare class LocalFacilitatorClient implements FacilitatorClient { private readonly f; constructor(facilitator: x402Facilitator); verify(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise; settle(paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise; getSupported(): Promise; } /** Create the complete x402 V2 stack with self-hosted facilitator, SIWx sessions, * and payment agreement support. * * Architecture: * 1. Self-hosted facilitator (we control settlement, no external dependency) * 2. Resource server with EVM price parsing * 3. SIWx extension for wallet-based sessions * 4. Payment-agreement extension for subscription terms * 5. Agreement-aware SIWx storage for hybrid access * * @param config - Stack configuration * @param routes - Route configurations for protected endpoints * @returns Complete x402 stack */ export declare function createX402Stack(config: X402StackConfig, routes: RoutesConfig): X402Stack; /** Create a complete x402 stack from environment variables. * Returns null if required keys are missing (graceful degradation). * * Unlike the server's version, this creates its own publicClient * directly from the RPC URL — no dependency on external singletons. * * **Payment recipient resolution (payTo):** * 1. `overrides.payTo` — explicit smart account address (highest priority) * 2. `X402_PAY_TO` env var — manual configuration * 3. **Auto-resolve** — queries the AzethFactory on-chain for the owner's * first smart account (derived from `AZETH_PRIVATE_KEY`) * * The auto-resolution ensures that providers using Azeth smart accounts * get reputation support by default — consumers can submit on-chain * opinions about your service. Using a plain EOA as payTo means * consumers cannot rate your service. * * **Facilitator key resolution (gas settlement):** * `X402_FACILITATOR_KEY` → `AZETH_PRIVATE_KEY` → `DEPLOYER_PRIVATE_KEY` * * @param routes - Route configurations for protected endpoints * @param overrides - Optional overrides for env-based defaults * @param overrides.payTo - Payment recipient address (overrides X402_PAY_TO and auto-resolution). * Should be your Azeth smart account for reputation support. */ export declare function createX402StackFromEnv(routes: RoutesConfig, overrides?: { payTo?: `0x${string}`; }): Promise; export { declareSIWxExtension } from '@x402/extensions/sign-in-with-x'; export { paymentMiddlewareFromHTTPServer } from '@x402/hono'; export type { RoutesConfig } from '@x402/core/server'; export type { x402HTTPResourceServer } from '@x402/core/server'; //# sourceMappingURL=stack.d.ts.map