import { wrapFetchWithPayment, decodeXPaymentResponse } from "x402-fetch";
import { account } from "./viem";
const fetchWithPayment = wrapFetchWithPayment(fetch, account);
const url =
"https://402.pinata.cloud/v1/retrieve/private/bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4";
fetchWithPayment(url, {
method: "GET",
})
.then(async (response) => {
const body = (await response.json()) as { url: string };
console.log(body);
})
.catch((error) => {
console.error(error.response?.data?.error);
});