/** * Twig Payments — x402 Gate * * Payment flow: * 1. First run is free (stores baseline). * 2. Subsequent runs require $TWIG_MONITOR_PRICE USDC on Base. * 3. CLI prints wallet address + amount, user pastes tx hash. * 4. We verify on-chain via Base RPC (public Etherscan-compatible endpoint). * 5. Fail-open: if verification fails, log warning, mark unverified, but allow. * 6. Receipts stored in ~/.twig/receipts/.json (append-only). * * Wallet address MUST be provided via TWIG_PAYMENT_ADDRESS env var. */ import type { PaymentGateResult, PaymentReceipt, PaymentRequest } from './types.js'; export declare const PAYMENT_AMOUNT_DEFAULT = "0.50"; export declare const PAYMENT_CURRENCY = "USDC"; export declare const PAYMENT_CHAIN: "base"; export declare function getPaymentAddress(): string; export declare function getPaymentAmount(): string; export declare function getReceiptsDir(baseDir?: string): string; export declare function loadReceipts(urlHash: string, baseDir?: string): PaymentReceipt[]; export declare function buildPaymentRequest(normalizedUrl: string): PaymentRequest; /** * Verify a USDC transfer on Base by checking the tx receipt via JSON-RPC. * * TODO: Implement real on-chain verification: * 1. Call eth_getTransactionReceipt with txHash via BASE_RPC_URL * 2. Decode the ERC-20 Transfer log (topic0 = keccak256("Transfer(address,address,uint256)")) * 3. Verify log.topics[2] (to address) == recipientAddress (checksummed) * 4. Verify log.data (value) >= expectedAmount (in USDC base units, 6 decimals) * 5. Verify the log's contract address == USDC contract on Base * * Until implemented, returns false. The fail-open path in checkPaymentGate * handles false correctly by allowing with an [PAYMENT UNVERIFIED] marker. */ export declare function verifyOnChain(_txHash: string, _recipientAddress: string, _amount: string): Promise; /** * Main gate function. * - isFirstRun: if true, allow free (no payment check). * - txHash: user-provided transaction hash. * - normalizedUrl: used to check existing receipts. * - baseDir: override storage directory (for tests). */ export declare function checkPaymentGate(opts: { isFirstRun: boolean; txHash?: string; normalizedUrl: string; baseDir?: string; }): Promise;