x402 is available on paid Pinata accounts. Upgrade your account to access x402 monetization features.
Prerequisites
- Paid Pinata account
- Pinata SDK installed
- Ethereum wallet address to receive payments
Step 1: Upload a Private File
First, upload a file to Private IPFS:cid for the next step.
Step 2: Create a Payment Instruction
Define your payment requirements:amount uses USDC’s smallest unit. USDC has 6 decimals, so to convert USD to the token amount, multiply by 1,000,000:
Formula: USD Amount × 1,000,000 = token amount
Networks:
- Production: Use
"base"(or"eip155:8453") with0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 - Testing: Use
"base-sepolia"(or"eip155:84532") with0x036CbD53842c5426634e7929541eC2318f3dCF7e
id for the next step.
Step 3: Attach CID to Payment Instruction
Link your private file to the payment instruction:Step 4: Share Your Monetized Content
Your file is now monetized! Share this URL with requesters:Replace
your-gateway.mypinata.cloud with your actual dedicated Pinata gateway domain (e.g., my-gateway.mypinata.cloud), and {cid} with your file’s CID.Step 5: Test the Payment Flow
When a requester accesses your URL without payment, the gateway returns a 402 response with payment requirements:X-Payment header.
Next Steps
- Manage Multiple Files: Attach multiple CIDs to the same payment instruction
- Update Pricing: Use
updatePaymentInstruction - Monitor Access: Check your gateway analytics to track paid downloads
- Requester Guide: Learn how requesters access paid content in the Accessing Paid Content guide