### Copy Example Environment File Source: https://docs.pinata.cloud/files/mpp/self-hosting Copy the example environment file to start configuring your variables. ```bash cp .dev.vars.example .dev.vars ``` -------------------------------- ### Install Plugin Response Source: https://docs.pinata.cloud/gateways/plugins/getting-started Example response when a plugin is successfully installed on a gateway. ```APIDOC ## Response ### Success Response (200) - **data** (object) - Contains details of the installed plugin. - **gateway_id** (string) - The ID of the gateway the plugin is installed on. - **plugin_id** (integer) - The ID of the installed plugin. ### Response Example ```json { "data": { "gateway_id": "8673cd80-bf53-4bca-b684-bec1d6bdf004", "plugin_id": 1 } } ``` ``` -------------------------------- ### List Agents Example Source: https://docs.pinata.cloud/tools/cli/agents This example demonstrates how to list all available agents. It's useful for getting an overview of existing agents. ```javascript import { listAgents } from "@pinata/sdk"; async function listAllAgents() { const agents = await listAgents(); console.log(agents); } listAllAgents(); ``` -------------------------------- ### Browse and Install Skills from ClawHub Source: https://docs.pinata.cloud/llms-full.txt Use the `clawhub` command to interact with the ClawHub marketplace. Options include listing, getting details, and installing skills. ```bash pinata agents clawhub list ``` ```bash pinata agents clawhub list --featured --sort newest ``` ```bash pinata agents clawhub get clawdhub ``` ```bash pinata agents clawhub install ``` -------------------------------- ### Setting Up Coinbase CDP Wallet Source: https://docs.pinata.cloud/files/x402/x402-accessing-paid-content This example shows how to initialize the Coinbase SDK and create a wallet instance using API keys and a private key. The `Wallet.create()` method is used to get the default address. ```javascript import { Coinbase, Wallet } from "@coinbase/coinbase-sdk"; const coinbase = new Coinbase({ apiKeyName: "YOUR_API_KEY_NAME", privateKey: "YOUR_PRIVATE_KEY", }); const wallet = await Wallet.create(); const account = await wallet.getDefaultAddress(); ``` -------------------------------- ### API Response Example Source: https://docs.pinata.cloud/api-reference/endpoint/ipfs/list-installed-plugins-for-gateway This is an example of a successful response (200 OK) when listing installed gateway plugins. It returns an array of objects, each containing a `gateway_id` and a `plugin_id`. ```json { "data": [ { "gateway_id": "2bfaa2ae-b590-4cb4-bb9c-5af43c2c9541", "plugin_id": 1 }, { "gateway_id": "2bfaa2ae-b590-4cb4-bb9c-5af43c2c9541", "plugin_id": 2 } ] } ``` -------------------------------- ### Create a New Remix Project Source: https://docs.pinata.cloud/llms-full.txt Use this command to start a new Remix project. Ensure you have Node.js and npm installed. ```bash npx create-remix@latest pinata-remix ``` -------------------------------- ### Pinata SDK Import and Hot Swap Example Source: https://docs.pinata.cloud/gateways/plugins/hot-swaps Demonstrates how to import the Pinata SDK and initiate a hot swap. This example requires the Pinata SDK to be installed. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK(); async function example() { const result = await pinata.pinByHash({ name: "my-new-file.txt", cid: "Qmabcdefghijklmnopqrstuvwxyz1234567890abcdef", gatewaySubdomain: "my-gateway.mypinata.cloud", }); console.log(result); } example(); ``` -------------------------------- ### Quick Start: Monetize Private IPFS Files Source: https://docs.pinata.cloud/llms-full.txt This example demonstrates the end-to-end process of monetizing a private file using the x402 protocol. It covers uploading a file, creating a payment instruction, attaching the file's CID to the instruction, and preparing the gateway URL for access. ```typescript 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} ``` -------------------------------- ### Create Next.js App Source: https://docs.pinata.cloud/llms-full.txt Starts a new Next.js project. Ensure you have Node.js and npm installed. ```bash npx create-next-app@latest ``` -------------------------------- ### Install a Skill Source: https://docs.pinata.cloud/tools/cli/agents Install a skill from the hub into your agent's library. Replace `` with the actual ID of the skill you wish to install. ```bash pinata agents clawhub install ``` -------------------------------- ### Demonstrating Pinata Hot Swaps Plugin Functionality Source: https://docs.pinata.cloud/llms-full.txt This example demonstrates uploading two files, creating a swap between their CIDs, and then fetching the swapped content through a gateway with the Hot Swaps plugin installed. It requires Pinata SDK initialization with JWT and gateway configuration. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "example.mypinata.cloud", // Gateway has Hot Swaps installed }); async function main() { try { // Upload the first file const file = new File(["The original CID"], "cid.txt", { type: "text/plain", }); const { IpfsHash: CID1 } = await pinata.upload.public.file(file); console.log("This is the original CID hash: ", CID1); // Upload a second file const file2 = new File(["The new CID"], "cid.txt", { type: "text/plain" }); const { IpfsHash: CID2 } = await pinata.upload.public.file(file2); console.log("This is the new CID hash: ", CID2); // Create the swap, so when we visit CID1 we will get the content of CID2 const swap = await pinata.files.public.addSwap({ cid: CID1, swapCid: CID2, }); console.log("Swap created: ", swap); // Fetch CID1 through our gateway that has Hot Swaps installed, get the content of CID2 const data = await pinata.gateways.public.get(CID1); console.log("Result of requestingt CID1 through the gateway: ", data); } catch (error) { console.log(error); } } main(); ``` -------------------------------- ### Install Gateway Plugin Response Source: https://docs.pinata.cloud/api-reference/endpoint/ipfs/install-gateway-plugin A successful installation returns a JSON object confirming the `gateway_id` and the installed `plugin_id`. ```json { "data": { "gateway_id": "3ced949f-2013-47a0-8f4a-f8d8e8ee14ac", "plugin_id": 1 } } ``` -------------------------------- ### Complete Integration Example for Accessing Paid Content Source: https://docs.pinata.cloud/files/x402/x402-accessing-paid-content This example demonstrates how to set up the wallet and use the `wrapFetchWithPayment` function from `@x402/fetch` to access paid content. Ensure you have your private key set in the environment variable `PRIVATE_KEY` and replace `your-gateway.mypinata.cloud` with your actual gateway URL. ```typescript import { wrapFetchWithPayment } from "@x402/fetch"; import { privateKeyToAccount } from "viem/accounts"; // Set up your wallet const account = privateKeyToAccount(process.env.PRIVATE_KEY); const fetchWithPayment = wrapFetchWithPayment(fetch, account); // Access paid content async function accessPaidContent(cid: string) { try { const url = `https://your-gateway.mypinata.cloud/x402/cid/${cid}`; const response = await fetchWithPayment(url); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const content = await response.json(); console.log("Content accessed successfully:", content); return content; } catch (error) { console.error("Failed to access content:", error); throw error; } } // Usage accessPaidContent("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4"); ``` -------------------------------- ### Install Pinata SDK and Tailwind CSS Source: https://docs.pinata.cloud/llms-full.txt Install the Pinata SDK and Tailwind CSS for styling. Tailwind CSS setup is optional and can be followed via its respective guide. ```bash npm i pinata ``` ```bash npx svelte-add@latest tailwindcss ``` -------------------------------- ### Install Gateway Plugin Source: https://docs.pinata.cloud/agents/api Install a plugin for an IPFS gateway. ```APIDOC ## POST /ipfs/gateways/{gatewayId}/plugins/{pluginId} ### Description Installs a plugin for a specific IPFS gateway. ### Method POST ### Endpoint /ipfs/gateways/{gatewayId}/plugins/{pluginId} ### Path Parameters - **gatewayId** (string) - Required - The ID of the gateway. - **pluginId** (string) - Required - The ID of the plugin to install. ### Request Body - **configuration** (object) - Optional - The configuration for the plugin. ### Response #### Success Response (200) - **status** (string) - The status of the installation operation. ### Response Example { "status": "success" } ``` -------------------------------- ### Get Payment Instruction Example Source: https://docs.pinata.cloud/sdk/x402/payment-instructions/get This example demonstrates how to call the getPaymentInstruction function. It requires a valid JWT for authentication. ```typescript const jwt = "01234567-89ab-cdef-0123-456789abcdef"; getPaymentInstruction(jwt); ``` -------------------------------- ### Setting Up Viem Local Account Source: https://docs.pinata.cloud/files/x402/x402-accessing-paid-content This snippet demonstrates how to create an account using a private key with Viem's `privateKeyToAccount` function. This account can then be used with x402 libraries. ```javascript import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); ``` -------------------------------- ### Example Key-Value Pair Source: https://docs.pinata.cloud/files/key-values This example shows how to structure a key-value pair for a file. It includes an environment and a user ID. ```json { "env": "prod", "userId": "abc123" } ``` -------------------------------- ### Complete Integration Example with Payment Wrapper Source: https://docs.pinata.cloud/files/x402/x402-accessing-paid-content This TypeScript example demonstrates a complete integration for accessing paid content. It includes setting up your wallet using a private key and wrapping fetch requests with payment logic. ```typescript import { wrapFetchWithPayment } from "@x402/fetch"; import { privateKeyToAccount } from "viem/accounts"; // Set up your wallet const account = privateKeyToAccount( process.env.PRIVATE_KEY ); ``` -------------------------------- ### Pinata Agents ClawHub Examples Source: https://docs.pinata.cloud/tools/cli/agents Provides example usage of the 'pinata agents clawhub' command, demonstrating how to list and install skills. ```shellscript #!/bin/bash pinata agents clawhub list --category "ai-agents" pinata agents clawhub install "@pinata/my-first-agent" pinata agents clawhub get "@pinata/my-first-agent" pinata agents clawhub install "@pinata/my-first-agent" --force pinata agents clawhub install "@pinata/my-first-agent" --pinata-path "./my-agents" pinata agents clawhub install "@pinata/my-first-agent" --pinata-path "./my-agents" --force ``` -------------------------------- ### API Reference - Introduction Source: https://docs.pinata.cloud/tools/erc-8004/services Getting started with the Pinata API. ```APIDOC ## API Reference - Introduction ### Description Getting started with the Pinata API. ``` -------------------------------- ### Get Payment Instruction Example Source: https://docs.pinata.cloud/sdk/x402/payment-instructions/get This example demonstrates how to call the getPaymentInstruction function with a specific ID. Ensure the ID is correctly formatted as a UUID. ```javascript function getPaymentInstruction(id) { return ( // ... other code _jsx("span", { className: "line", children: _jsx("span", { style: { color: "#8250DF", "--shiki-dark": "#DCDCAA" }, children: "getPaymentInstruction" }) }), _jsx("span", { className: "line", children: _jsx("span", { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "(" }) }), "\n", _jsx("span", { className: "line", children: _jsx("span", { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"01234567-89ab-cdef-0123-456789abcdef\"" }) }), "\n", _jsx("span", { className: "line", children: _jsx("span", { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ");" }) }), "\n" // ... other code ); } ``` -------------------------------- ### JavaScript Example Source: https://docs.pinata.cloud/api-reference/endpoint/ipfs/list-marketplace-plugins This example demonstrates how to fetch a list of marketplace plugins using JavaScript. It assumes you have the necessary authentication headers configured. ```javascript self.__next_f.push([1, "4e:I[448287,[\"/mintlify-assets/_next/static/chunks/de15d9642f7c974c.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/b664fc8bb1e7ab0d.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/d53146a6ec2c0f8b.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/07eb678ee01a9cdf.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/90079180db6f14a4.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/1eb43db430214ebb.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/247f8594ded6e6f1.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/7285fd2749e1c6b9.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/6fd3acb5d5a9a0e5.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/bdb898abfe5bae4d.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/2fc1f5c43394028e.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/ef0afc2d4a237848.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/b61dd8de8e9eb001.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/50537af49df8455c.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/204e747b034398c6.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/13ebb4257dd3a545.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/f38a90b321f341ae.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/67864c9d5997176d.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/55341d0a0dea6975.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/190e2d29d3b2239b.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/24ea02e20ac4ff55.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/d31db8d969fc01f1.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/d13ca95e8b427f83.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/e945895a97de48c6.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\",\"/mintlify-assets/_next/static/chunks/e92309faf83811de.js?dpl=dpl_ExaQdkRaa4HqJC5Uuz5xsdjEdxnq\"],"default",1] ``` -------------------------------- ### Upload Command Example Source: https://docs.pinata.cloud/tools/cli/ipfs This example demonstrates the basic usage of the 'upload' command in the Pinata CLI. Ensure you have the CLI installed and configured with your API keys. ```text NAME: pinata-cli-ipfs-upload - Upload a file or directory to IPFS SYNOPSIS: pinata-cli ipfs upload [options] DESCRIPTION: Uploads the specified file or directory to IPFS via Pinata. OPTIONS: --pinata-gateway Specify a custom Pinata gateway URL. --pinata-api-key Your Pinata API key. --pinata-secret-api-key Your Pinata Secret API key. --pinata-bypass-gateway-cache Bypass gateway cache for the upload. --pinata-pin-name Assign a custom name to the pinned content. --pinata-metadata Add custom JSON metadata to the pinned content. --pinata-pin-policy Specify the pinning policy (e.g., "pin", "pin-by-hash"). --pinata-disable-all-pinning Disable all pinning services for this upload. --pinata-hidden Mark the content as hidden. --pinata-wrap-with-directory Wrap the content in a directory before uploading. --pinata-cid-version Specify the CID version to use (e.g., 1). --pinata-shard-size Specify the shard size for large files. --pinata-recursive Recursively upload contents of a directory. --pinata-no-prefix Do not add a prefix to the CID. --pinata-force-overwrite Force overwrite of existing content with the same name. --pinata-pin-to-existing-pin Pin to an existing Pinata pin. --pinata-pin-to-existing-pin-name Name of the existing Pinata pin to pin to. --pinata-pin-to-existing-pin-metadata Metadata for pinning to an existing pin. --pinata-pin-to-existing-pin-policy Pinning policy for pinning to an existing pin. --pinata-pin-to-existing-pin-disable-all-pinning Disable all pinning services for existing pin. --pinata-pin-to-existing-pin-hidden Mark existing pin as hidden. --pinata-pin-to-existing-pin-wrap-with-directory Wrap existing pin content in a directory. --pinata-pin-to-existing-pin-cid-version CID version for existing pin. --pinata-pin-to-existing-pin-shard-size Shard size for existing pin. --pinata-pin-to-existing-pin-recursive Recursively pin to existing pin. --pinata-pin-to-existing-pin-no-prefix No prefix for existing pin. --pinata-pin-to-existing-pin-force-overwrite Force overwrite for existing pin. EXAMPLES: pinata-cli ipfs upload ./my-file.txt pinata-cli ipfs upload ./my-directory --pinata-pin-name "My Awesome Directory" pinata-cli ipfs upload ./my-image.jpg --pinata-recursive --pinata-cid-version 1 ``` -------------------------------- ### Example Usage of get() for a CID Source: https://docs.pinata.cloud/sdk/gateways/private/get Demonstrates how to call the `get` method with a specific CID to retrieve associated data from Pinata's private gateway. ```typescript import( "@pinata/sdk" ); const pinata = new Pinata(); async function example() { const result = await pinata.get("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4"); console.log(result); } ``` -------------------------------- ### Create index.js and hello-world.txt Source: https://docs.pinata.cloud/llms-full.txt Creates the necessary JavaScript file for the upload logic and a sample text file. ```bash touch index.js && touch hello-world.txt ``` -------------------------------- ### Clone and Install Dependencies Source: https://docs.pinata.cloud/llms-full.txt Clone the repository, navigate to the directory, and install project dependencies using bun. ```bash git clone https://github.com/PinataCloud/erc8004 cd erc8004 bun install cp .env.example .env # fill in your values ``` -------------------------------- ### Set up Viem Local Account Source: https://docs.pinata.cloud/files/x402/x402-accessing-paid-content This TypeScript snippet demonstrates how to import necessary components from Viem for setting up a local account. This is a prerequisite for using x402 client libraries. ```typescript import { createPublicClient, http } from "viem" import { foundry } from "viem/chains" const client = createPublicClient({ chain: foundry, transport: http() }) ``` -------------------------------- ### Get Plugins for Gateway Source: https://docs.pinata.cloud/gateways/plugins/getting-started Endpoint to list installed plugins for a specific gateway. ```APIDOC ## GET /ipfs/gateway_plugins/:gateway_id ### Description This endpoint retrieves a list of all plugins installed on a specific gateway. ### Method GET ### Endpoint `/ipfs/gateway_plugins/:gateway_id` ### Parameters #### Path Parameters - **gateway_id** (string) - Required - The unique identifier for the gateway. ``` -------------------------------- ### Install Pinata and Adapters Source: https://docs.pinata.cloud/llms-full.txt Navigate into the created project directory and install the Pinata SDK along with necessary adapters like Vercel and Svelte. ```bash cd pinata-astro && npm i pinata ``` ```bash npx astro add vercel svelte ``` -------------------------------- ### Using @x402/axios to Access Paid Content Source: https://docs.pinata.cloud/files/x402/x402-accessing-paid-content This example shows how to integrate the `@x402/axios` library to automatically manage X402 payments when making requests with Axios. It requires a Viem account and wraps the Axios instance. ```javascript import { wrapAxiosWithPayment } from "@x402/axios"; import axios from "axios"; import { privateKeyToAccount } from "viem/accounts"; // Set up your wallet const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); const axiosWithPayment = wrapAxiosWithPayment(axios, account); // Automatically handles 402 response and payment const response = await axiosWithPayment.get( "https://your-gateway.mypinata.cloud/x402/cid/bafkreih..." ); console.log(response.data); ``` -------------------------------- ### Example Usage of predictCID Source: https://docs.pinata.cloud/files/uploading-files This example demonstrates how to use the predictCID function with a local file. It reads the file using Node.js 'fs' module and then calls predictCID to get the CID. ```javascript import fs from "fs" const file = new File([fs.readFileSync("path/to-file")], "filename.extension"); const cid = await predictCID(file, 1); console.log(cid); ``` -------------------------------- ### Get Installed Plugins for a Gateway API Source: https://docs.pinata.cloud/llms-full.txt Retrieve a list of all plugins currently installed on a specific Dedicated Gateway. The gateway ID is required as a path parameter. Requires your Pinata JWT. ```typescript const gatewayId = "8673cd80-bf53-4bca-b684-bec1d6bdf004" const installPlugin = await fetch(`https://api.pinata.cloud/v3/ipfs/gateway_plugins/${gatewayId}`, { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Bearer ${PINATA_JWT}` } }) ``` ```json { "data": { "gateway_id": "8673cd80-bf53-4bca-b684-bec1d6bdf004", "plugin_id": 1 } } ``` -------------------------------- ### Example Workflow: Upload and Create Payment Instruction Source: https://docs.pinata.cloud/files/x402/intro This TypeScript example demonstrates how to initialize the Pinata SDK, upload a file, and create a payment instruction for monetizing content via the x402 protocol. Remember to replace placeholder values with your actual gateway domain. ```typescript const pinata = new PinataSDK(process.env.PINATA_API_KEY, process.env.PINATA_SECRET_API_KEY); const uploadFile = async () => { const readableStreamForFile = fs.createReadStream("./path/to/your/file.txt"); const result = await pinata.pinFileToIPFS(readableStreamForFile); return result.IpfsHash; }; const createPaymentInstruction = async (cid: string) => { const paymentInstruction = await pinata.createPaymentInstruction({ name: "My Private File", description: "Access to my private file", privateFile: cid, // Example for Base Mainnet paymentToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", paymentAmount: "1000000", // 1 USDC paymentType: "USDC", gateway: "your-gateway.mypinata.cloud", }); return paymentInstruction; }; const runWorkflow = async () => { try { const cid = await uploadFile(); console.log("File uploaded with CID:", cid); const paymentInstruction = await createPaymentInstruction(cid); console.log("Payment Instruction created:", paymentInstruction); console.log( `Share this URL for access: https://${paymentInstruction.gateway}/x402/cid/${paymentInstruction.id}` ); } catch (error) { console.error("Error during workflow:", error); } }; runWorkflow(); ``` -------------------------------- ### Create Payment Instruction Example Source: https://docs.pinata.cloud/sdk/x402/payment-instructions/create This example demonstrates how to create a payment instruction for a digital asset. It includes details such as the name of the content, the asset's contract address, the payment recipient, the network, and the amount. ```javascript await pinata.x402.createPaymentInstruction({ name: "Premium Content Access", payment_requirements: [ { asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base pay_to: "0x1234567890abcdef1234567890abcdef12345678", network: "base", amount: "10000" // $0.01 in USDC (6 decimals) } ] }); ``` -------------------------------- ### Get Signature for CID Source: https://docs.pinata.cloud/sdk/signatures/public/get This example demonstrates how to initialize the Pinata SDK and retrieve the signature for a specific CID. ```APIDOC ## GET /public/get ### Description Retrieves the signature for a given CID. ### Method GET ### Endpoint `/public/get` ### Parameters #### Query Parameters - **cid** (string) - Required - The Content Identifier (CID) for which to retrieve the signature. ### Response #### Success Response (200) - **signature** (string) - The signature associated with the provided CID. #### Response Example ```json { "signature": "your_signature_here" } ``` ``` -------------------------------- ### Example Wallet Client Configuration with viem Source: https://docs.pinata.cloud/llms-full.txt Sets up a viem wallet client to interact with a user's Ethereum wallet. This configuration is necessary for signing typed data. ```typescript import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' export const walletClient = createWalletClient({ chain: mainnet, transport: custom(window.ethereum!), }) export const [account] = await walletClient.getAddresses() ↑ JSON-RPC Account // export const account = privateKeyToAccount(...) ↑ Local Account ``` -------------------------------- ### Example: Get Channel Status Source: https://docs.pinata.cloud/llms-full.txt Command to retrieve the current status of an agent's channel configuration. ```bash # Get channel status pinata agents channels status ``` -------------------------------- ### Create Node.js Project and Install Dependencies Source: https://docs.pinata.cloud/llms-full.txt Initializes a new Node.js project and installs the Pinata SDK and dotenv for environment variables. ```bash mkdir pinata-starter && cd pinata-starter && npm init -y ``` ```bash npm i pinata dotenv ``` -------------------------------- ### Create Public Group Example Source: https://docs.pinata.cloud/sdk/groups/public/create Demonstrates how to create a public group. Ensure you have the necessary SDK setup. ```typescript "use strict"; const {Fragment: _Fragment, jsx: _jsx, jsxs: _jsxs} = arguments[0]; const {useMDXComponents: _provideComponents} = arguments[0]; function _createMdxContent(props) { const _components = { code: "code", li: "li", p: "p", pre: "pre", span: "span", ul: "ul", ..._provideComponents(), ...props.components }, {CodeBlock, Heading} = _components; if (!CodeBlock) _missingMdxReference("CodeBlock", true); if (!Heading) _missingMdxReference("Heading", true); return _jsxs(_Fragment, { children: [_jsx(_components.p, { children: "Create a public group" }), "\n", _jsx(Heading, { level: "2", id: "usage", children: "Usage" }), "\n", _jsx(CodeBlock, { filename: "", numberOfLines: "10", language: "typescript", children: _jsx(_components.pre, { className: "shiki shiki-themes github-light-default dark-plus", style: { backgroundColor: "#ffffff", "--shiki-dark-bg": "#0B0C0E", color: "#1f2328", "--shiki-dark": "#D4D4D4" }, language: "typescript", children: _jsxs(_components.code, { language: "typescript", numberOfLines: "10", children: [_jsxs(_components.span, { className: ``` -------------------------------- ### List available skills Source: https://docs.pinata.cloud/llms-full.txt Lists all available skills in the Pinata library. No setup is required beyond having the CLI installed. ```bash pinata agents skills list ``` -------------------------------- ### Complete Example Manifest.json Source: https://docs.pinata.cloud/llms-full.txt A comprehensive manifest.json example demonstrating agent identity, secrets, skills, lifecycle scripts, a web route, and a scheduled task. ```json { "$schema": "https://agents.pinata.cloud/schemas/manifest.v1.json", "version": 1, "engine": "openclaw", "agent": { "name": "Useful Assistant", "description": "Personal AI helper with file reading, web search, and memory management", "emoji": "🧠", "vibe": "Resourceful and opinionated" }, "template": { "slug": "useful-assistant", "category": "general", "partnerName": "Pinata", "tags": ["assistant", "personal", "productivity"] }, "secrets": [ { "name": "EXAMPLE_API_KEY", "description": "Optional API key for external service", "required": false } ], "scripts": { "build": "cd workspace/projects/hello-test && npm install --include=dev", "start": "cd workspace/projects/hello-test && npx vite --host 0.0.0.0" }, "skills": [ { "clawhub_slug": "@pinata/api", "name": "Pinata API" } ], "routes": [ { "port": 5173, "path": "/app", "protected": false } ], "tasks": [ { "name": "daily-check-in", "schedule": { "kind": "cron", "expr": "0 9 * * *" }, "payload": { "kind": "agentTurn", "text": "Good morning! Review my workspace and suggest priorities for today." } } ] } ``` -------------------------------- ### List All Agents Source: https://docs.pinata.cloud/llms-full.txt Use this command to view all agents currently registered. No setup is required beyond having the CLI installed. ```bash NAME: pinata agents list - List all agents USAGE: pinata agents list [options] OPTIONS: --help, -h show help ``` -------------------------------- ### Install and Run ERC-8004 Wizard Source: https://docs.pinata.cloud/llms-full.txt Use this command to quickly set up and run the ERC-8004 wizard for an interactive experience. Ensure you have Node.js and npm installed. ```bash npx @pinata/erc8004-wizard ``` -------------------------------- ### Node.js Example: Pin File to IPFS with Fetch Source: https://docs.pinata.cloud/api-reference/endpoint/ipfs/pin-file-to-ipfs This example shows how to pin a file to IPFS using Node.js and the `fetch` API. It includes setting up the request with necessary headers, including authorization, and sending the file data in the request body. ```javascript const fs = require('fs'); const JWT = "YOUR_JWT"; const JWT_KEY = `Bearer ${JWT}`; const upload = async () => { const file = fs.createReadStream('./path/to/your/file.txt'); const formData = new FormData(); formData.append('file', file); const res = await fetch('https://api.pinata.cloud/pinning/pinFileToIPFS', { method: 'POST', headers: { Authorization: JWT_KEY, }, body: formData }); const data = await res.json(); console.log(data); }; upload(); ``` -------------------------------- ### Get Public Signature - TypeScript Source: https://docs.pinata.cloud/files/signatures Retrieves a public signature from Pinata. Ensure you have the necessary Pinata SDK setup. ```typescript const signature = await pinata.signatures.public.get("QmXGeVy9dVwfuFJmvbzz8y4dYK1TdxXbDGzwbNuyZ5xXSU"); ``` -------------------------------- ### Pinata SDK Import Example Source: https://docs.pinata.cloud/files/x402/intro This snippet shows how to import the PinataSDK for use in your TypeScript project. Ensure you have the SDK installed. ```typescript import { PinataSDK } from "pinata" ``` -------------------------------- ### Setting Up Wallet Account Source: https://docs.pinata.cloud/files/x402/x402-accessing-paid-content Creates a wallet account using a private key stored in environment variables. This account will be used for transactions related to paid content. ```typescript // Set up your wallet const account = privateKeyToAccount( process.env.PRIVATE_KEY ); ``` -------------------------------- ### Delete Signature Example Source: https://docs.pinata.cloud/sdk/signatures/public/delete This TypeScript code snippet demonstrates how to delete an EIP-712 signature from a CID. Ensure you have the necessary SDK setup. ```typescript import pinataSDK from "@pinata/sdk"; const pinata = new pinataSDK("YOUR_PINATA_JWT"); async function deleteSignature() { try { const cid = "YOUR_CID"; const signatureId = "YOUR_SIGNATURE_ID"; await pinata.deleteSignature(cid, signatureId); console.log("Signature deleted successfully"); } catch (error) { console.error("Error deleting signature:", error); } } deleteSignature(); ``` -------------------------------- ### Astro Integration Setup Source: https://docs.pinata.cloud/llms-full.txt Guide to setting up Pinata with Astro. This involves creating an API key and obtaining your Gateway URL from the Pinata dashboard. ```javascript const gatewayUrl = "aquamarine-casual-tarantula-177.mypinata.cloud"; const apiKey = "YOUR_API_KEY"; const apiSecret = "YOUR_API_SECRET"; // Example of how you might use these in an Astro component or service // This is illustrative and not a complete implementation. async function pinFileToPinata(file) { const formData = new FormData(); formData.append('file', file); const response = await fetch(`https://${gatewayUrl}/pinning/pinFileToIPFS`, { method: 'POST', headers: { 'pinata_api_key': apiKey, 'pinata_secret_api_key': apiSecret }, body: formData }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return await response.json(); } ``` -------------------------------- ### Get File Access Counts with Pinata SDK Source: https://docs.pinata.cloud/sdk/analytics/requests Retrieve the number of times files have been accessed. This example shows how to call the analytics requests function. ```typescript const files = await pinata.analytics.requests() .days(7) .userAgent() ``` -------------------------------- ### Agent Console Output Example Source: https://docs.pinata.cloud/agents/console This example shows the typical output from an agent's console, including the working directory and prompt. ```text --- Agent Console --- Working directory: /home/node/clawd/workspace ~/clawd/workspace $ ``` -------------------------------- ### Get Payment Instruction by ID Source: https://docs.pinata.cloud/sdk/x402/payment-instructions/get This example demonstrates how to import the Pinata SDK, initialize it with your JWT, and then call the function to retrieve a specific payment instruction by its ID. ```APIDOC ## Get Payment Instruction by ID ### Description Retrieve a specific payment instruction by ID. ### Method GET ### Endpoint `/x402/payment-instructions/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the payment instruction to retrieve. ### Request Example ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT! }); // Assuming you have a payment instruction ID const paymentInstructionId = "some-instruction-id"; pinata.paymentInstructions.get(paymentInstructionId).then(data => { console.log(data); }).catch(error => { console.error(error); }); ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the payment instruction. - **amount** (number) - The amount associated with the payment instruction. - **currency** (string) - The currency of the payment instruction. - **status** (string) - The current status of the payment instruction (e.g., 'pending', 'paid', 'failed'). - **createdAt** (string) - The timestamp when the payment instruction was created. - **updatedAt** (string) - The timestamp when the payment instruction was last updated. #### Response Example ```json { "id": "some-instruction-id", "amount": 100.50, "currency": "USD", "status": "pending", "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Install Gateway Plugin Source: https://docs.pinata.cloud/api-reference/endpoint/ipfs/install-gateway-plugin This section details the process of installing a gateway plugin. Please refer to the specific plugin documentation for detailed instructions and configuration options. ```APIDOC ## POST /gateway/plugins/install ### Description Installs a gateway plugin for your Pinata account. ### Method POST ### Endpoint /gateway/plugins/install ### Request Body - **pluginId** (string) - Required - The unique identifier of the plugin to install. - **configuration** (object) - Optional - Configuration parameters specific to the plugin. ### Request Example ```json { "pluginId": "your-plugin-id", "configuration": { "setting1": "value1", "setting2": "value2" } } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the plugin was installed successfully. #### Response Example ```json { "message": "Plugin 'your-plugin-id' installed successfully." } ``` ``` -------------------------------- ### Optimize Image with SDK Source: https://docs.pinata.cloud/llms-full.txt Example of optimizing an image using the `optimizeImage` method available on the `get` method of the Pinata SDK. This allows for resizing and format conversion. ```APIDOC ## Optimize Image with SDK ### Description This method allows you to optimize an image by specifying parameters such as width, height, DPR, fit, quality, format, and more. It is accessible via the `get` method of the Pinata SDK. ### Method `optimizeImage(options: OptimizeImageOptions)` ### Parameters #### `OptimizeImageOptions` Object - **width** (number) - Optional - The desired width of the image in pixels. - **height** (number) - Optional - The desired height of the image in pixels. - **dpr** (number) - Optional - The device pixel ratio for the image. - **fit** (string) - Optional - How the image should be resized. Options: `scaleDown`, `contain`, `cover`, `crop`, `pad`. - **gravity** (string) - Optional - Specifies the direction for cropping or padding. Options: `auto`, `side`, or a custom string. - **quality** (number) - Optional - The quality of the output image (1-100). - **format** (string) - Optional - The desired output format. Options: `auto`, `webp`. If `auto`, it will try to serve the best format. - **animation** (boolean) - Optional - Whether to preserve animation for GIF inputs. - **sharpen** (number) - Optional - The amount of sharpening to apply to the image. - **onError** (boolean) - Optional - Whether to return an error if optimization fails. - **metadata** (string) - Optional - How to handle image metadata. Options: `keep`, `copyright`, `none`. ### Request Example ```typescript const data = await pinata.gateways.public .get("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4") .optimizeImage({ width: 500, height: 500, format: "webp" }); ``` ### Response Returns the optimized image data. ```