import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm";
import { wrapFetchWithPayment } from "@x402/fetch";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client().register("eip155:84532",
new ExactEvmScheme(privateKeyToAccount(process.env.WALLET_PRIVATE_KEY))
);
const paidFetch = wrapFetchWithPayment(fetch, client);
const response = await paidFetch(
"https://x402.goldrush.dev/v1/eth-mainnet/address/aave.eth/balances_v2/"
);
const balances = await response.json();
console.log(JSON.stringify({
headers: Object.fromEntries(response.headers.entries()),
body: balances,
}, null, 2));