Skip to content

PinataCloud/x402-hackathon-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x402 Hackathon Demo

Complete example showing how to monetize private IPFS files using Pinata's x402 protocol.

Quick Start

  1. Install dependencies:
bun install
  1. Set environment variables:
cp .env.example .env
# Edit .env with your actual values

Or export directly:

export PINATA_JWT="your_pinata_jwt_here"
export WALLET_ADDRESS="your_ethereum_wallet_address"
export GATEWAY_DOMAIN="your-gateway.mypinata.cloud"  # Optional
  1. Run the demo:
bun start

Configuration

All configuration is set via constants at the top of x402-demo.ts:

  • PRICE_USD: Price in USD (default: $1.00)
  • NETWORK: Blockchain network ("base" for production, "base-sepolia" for testing)
  • USDC_CONTRACT: USDC contract address (auto-configured based on network)
  • FILE_CONTENT: Content of the file to monetize

What It Does

  1. Uploads a private file to Pinata's Private IPFS network
  2. Creates a payment instruction with your price and wallet
  3. Links the file to payment requirements
  4. Tests the payment flow by accessing the monetized URL
  5. Provides the shareable URL for requesters

Output

The demo will output a URL like:

https://your-gateway.mypinata.cloud/x402/cid/QmYourFileHash

When requesters access this URL without payment, they'll receive a 402 response with payment requirements. After payment, they can access the file.

Next Steps

  • Replace the gateway domain with your actual Pinata gateway
  • Share the monetized URL with requesters
  • Monitor your wallet for incoming payments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published