import { Mppx, tempo } from "mppx/client";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY");
const mppx = Mppx.create({ methods: [tempo({ account })] });
// 1. Get a signed upload URL (handles 402 payment automatically)
const response = await mppx.fetch(
"https://mpp.pinata.cloud/v1/pin/public?fileSize=1024",
{ method: "POST" }
);
const { url } = await response.json();
// 2. Upload your file to the signed URL
const file = new File(["hello world"], "hello.txt", { type: "text/plain" });
const formData = new FormData();
formData.append("file", file);
await fetch(url, {
method: "POST",
body: formData,
});