Overview
Pinata provides IPFS pinning services that zkStorage uses to store encrypted files. Files are encrypted client-side before upload, then pinned to IPFS via Pinata’s API.How It Works
- Encrypt: Files encrypted client-side with AES-256-GCM
- Upload: Encrypted blob uploaded to Pinata API
- Pin: Pinata pins the file to IPFS network
- CID: Returns Content Identifier (CID) for retrieval
- Download: Fetch via Pinata gateway, decrypt client-side
Features
- Fast Uploads - Direct upload to Pinata with retry logic
- Gateway Access - Downloads via gateway.pinata.cloud
- Metadata Storage - Separate CID for file metadata
- Multi-Gateway Fallback - Cloudflare and ipfs.io as backup
Integration with zkStorage
zkStorage uses Pinata for all IPFS operations:Terminal Commands
zkStorage commands that use Pinata:API Details
Upload to Pinata
zkTerm uploads encrypted files using Pinata’s pinFileToIPFS endpoint:Download from Gateway
Downloads use the Pinata gateway with fallbacks:File Structure
Each zkStorage upload creates two IPFS objects:| Object | Content | CID Example |
|---|---|---|
| Encrypted File | AES-256-GCM encrypted data | QmXyz123... |
| Metadata | IV, salt, original name/size | QmAbc456... |
Error Handling
| Error | Cause | Solution |
|---|---|---|
PINATA_JWT not configured | Missing API key | Set PINATA_JWT env var |
Upload failed: 401 | Invalid JWT | Regenerate Pinata API key |
Gateway timeout | IPFS propagation delay | Retry or use fallback gateway |
CID not found | File unpinned | Re-upload the file |
Retry Logic
Uploads include automatic retry with exponential backoff:Timeouts
| Operation | Timeout |
|---|---|
| File upload | 60 seconds |
| Gateway fetch | 30 seconds |
| Metadata fetch | 30 seconds |
Environment Variables
| Variable | Description |
|---|---|
PINATA_JWT | Pinata API JWT token (required) |
Getting a Pinata API Key
- Create account at pinata.cloud
- Go to API Keys section
- Create new key with
pinFileToIPFSpermission - Copy JWT token to
PINATA_JWTenvironment variable
Pricing
Pinata offers:- Free tier: 1GB storage, 100 pins
- Starter: $20/month, 25GB storage
- Professional: Custom pricing
Migration Notes
zkStorage previously used NFT.Storage (deprecated June 2024). Migration to Pinata provides:- Better upload reliability
- Faster gateway access
- Active maintenance and support