Account-Free IPFS Uploads From Pinata
Use crypto to pay for private and public IPFS uploads without creating an account or using an API key
- Leverages Coinbase's x402 Protocol
- Public IPFS content available on public gateways or your own Dedicated IPFS Gateway
- Pay to retrieve private IPFS content
// Asynchronous function to upload a private file with payment
(async () => {
try {
const response = await fetchWithPayment(
`https://402.pinata.cloud/v1/pin/private`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
fileSize: SIZE, // The size of the file you'll be uploading
}),
}
);
const urlData = await response.json();
const file = new File([Date.now().toString()], "hello.txt", { type: "text/plain" })
const upload = await pinata.upload.private.file(file).url(urlData.url);
console.log(upload)
} catch (error) {
console.error(error);
}
})();