import { CdpX402Client } from "@coinbase/cdp-sdk/x402"; import { wrapFetchWithPayment } from "@x402/fetch"; // Production mode uses Base Mainnet. The CDP wallet must hold native Circle USDC on Base. const client = new CdpX402Client(); const { evmAddress } = await client.getAddresses(); console.log(`Paying from ${evmAddress}`); const fetchWithPayment = wrapFetchWithPayment(globalThis.fetch, client); const response = await fetchWithPayment("https://api.tradingzones.app/v1/signals/TZ-SELECT/4h"); if (!response.ok) { throw new Error(`Trading Zones purchase failed: HTTP ${response.status}`); } const setup = await response.json(); if (!setup.schema_version || !setup.package_id || !setup.valid_until) { throw new Error("Invalid Trading Zones response contract"); } console.log(JSON.stringify(setup, null, 2));