> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pinata.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

<Note>
  x402 is available on paid Pinata accounts. [Upgrade your account](https://app.pinata.cloud/billing) to access x402 monetization features.
</Note>

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

| Network                | USDC Token Address                           | Use Case                |
| ---------------------- | -------------------------------------------- | ----------------------- |
| Base (Mainnet)         | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | Production monetization |
| Base Sepolia (Testnet) | `0x036CbD53842c5426634e7929541eC2318f3dCF7e` | Testing 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

<Note>
  You must use your own dedicated Pinata gateway domain. Replace `your-gateway.mypinata.cloud` with your actual gateway domain throughout these examples.
</Note>

## Example Workflow

```typescript theme={null}
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

<CardGroup cols={2}>
  <Card title="x402 Overview" icon="sparkle" href="/sdk/x402/index">
    Get started with x402 monetization
  </Card>

  <Card title="Payment Instructions" icon="code" href="/sdk/x402/payment-instructions/list">
    Create and manage payment instructions
  </Card>

  <Card title="CID Management" icon="link" href="/sdk/x402/cids/list">
    Attach CIDs to payment instructions
  </Card>

  <Card title="Types" icon="brackets-curly" href="/sdk/types/x402">
    TypeScript type definitions
  </Card>
</CardGroup>

## API Reference

For direct API access, see the [x402 API documentation](/api-reference/endpoint/x402/payment-instructions-list).
