Skip to main content
x402 is available on paid Pinata accounts. Upgrade your account to access x402 monetization features.
Monetize your private IPFS files by receiving USDC payments directly to your wallet using the x402 protocol. For detailed concepts and workflows, see the x402 Introduction.

Quick Example

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 Access",
  payment_requirements: [
    {
      asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base
      pay_to: "0xYourWalletAddress", // YOU receive payments here
      network: "base",
      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}

Network Configuration

USDC is currently the only supported token.
NetworkUSDC Token AddressUse Case
Base (Mainnet)0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913Production monetization
Base Sepolia (Testnet)0x036CbD53842c5426634e7929541eC2318f3dCF7eTesting payment flows

Payment Amounts

USDC has 6 decimals. To convert USD to token amount, multiply by 1,000,000:
USDamount
$0.01"10000"
$0.10"100000"
$1.00"1000000"

Available Methods

Payment Instructions

  • list - List all payment instructions
  • create - Create a new payment instruction
  • get - Get a payment instruction by ID
  • update - Update a payment instruction
  • delete - Delete a payment instruction

CID Management

  • list - List CIDs attached to a payment instruction
  • add - Attach a CID to a payment instruction
  • remove - Remove a CID from a payment instruction