Skip to main content
x402 is available on paid Pinata accounts. Upgrade your account to access x402 monetization features.
Pinata’s x402 enables you to monetize your private IPFS files by receiving USDC payments directly to your wallet. You set the price, you receive the payment.

Overview

Pinata’s x402 implementation enables:
  • Monetization of private IPFS content using Payment Instructions
  • You receive payments directly to your wallet address. Payments go to you.
  • Flexible payment requirements configurable per file or group of files
  • USDC payments on Base (mainnet) and Base Sepolia (testnet). USDC is currently the only supported token.
  • Gateway-level enforcement through the x402 protocol

Network Configuration

NetworkUSDC Token AddressUse Case
Base (Mainnet)0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913Production monetization
Base Sepolia (Testnet)0x036CbD53842c5426634e7929541eC2318f3dCF7eTesting payment flows

How It Works

  1. Upload a private file to Pinata IPFS
  2. Create a Payment Instruction with your desired payment requirements
  3. Attach the CID of your private file to the Payment Instruction
  4. Share your x402 gateway URL: https://your-gateway.mypinata.cloud/x402/cid/{cid}
  5. Requesters make USDC payments through your gateway to access content
You must use your own dedicated Pinata gateway domain. Replace your-gateway.mypinata.cloud with your actual gateway domain throughout these examples.

Example Workflow

import { PinataSDK } from "pinata";

const pinata = new PinataSDK({
  pinataJwt: process.env.PINATA_JWT!,
  pinataGateway: "your-gateway.mypinata.cloud",
});

// 1. Upload a private file
const file = new File(["premium content"], "content.pdf", { type: "application/pdf" });
const upload = await pinata.upload.private.file(file);

// 2. Create a payment instruction
const instruction = await pinata.x402.createPaymentInstruction({
  name: "Premium Content",
  payment_requirements: [
    {
      asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      pay_to: "0xYourWalletAddress", // YOU receive payments here
      network: "base",
      description: "Access fee",
      amount: "10000", // $0.01 in USDC
    },
  ],
});

// 3. Attach CID to payment instruction
await pinata.x402.addCid(instruction.data.id, upload.cid);

// 4. Share the x402 gateway URL
// https://your-gateway.mypinata.cloud/x402/cid/{cid}

Why Use Payment Instructions

Payment Instructions enable you to monetize your private content by setting custom payment requirements and receiving payments directly to your wallet. Key benefits:
  • You get paid for your content. Set your own prices and receive USDC payments directly.
  • Flexible pricing for different files or groups of files
  • Reusable payment instructions that can be attached to multiple CIDs
  • Full control over payment requirements, pricing, and access

SDK Reference

API Reference

For direct API access, see the x402 API documentation.