Skip to main content
Glama

updatePaymentInstruction

Modify existing payment instructions for USDC transactions on Base networks by updating recipient addresses, amounts, descriptions, and network settings.

Instructions

Update an existing x402 payment instruction. Currently supports USDC (6 decimals) on Base/Base Sepolia only.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe unique identifier of the payment instruction to update
nameNoUpdated name
pay_toNoUpdated wallet address (0x...) to receive USDC payments
amount_usdcNoUpdated price in USD as a string (e.g., '0.01' for 1 cent, '1.50' for $1.50)
networkNoUpdated blockchain network
descriptionNoUpdated description

Implementation Reference

  • The handler function that executes the updatePaymentInstruction tool logic. It constructs a PATCH request to the Pinata API to update payment instructions, converting USD amounts to USDC smallest units (6 decimals) and building the payload conditionally based on provided parameters.
    async ({ id, name, pay_to, amount_usdc, network, description }) => {
      try {
        const url = `https://api.pinata.cloud/v3/x402/payment_instructions/${id}`;
    
        // USDC contract addresses
        const USDC_ADDRESSES: Record<string, string> = {
          "base": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
        };
    
        const payload: {
          name?: string;
          payment_requirements?: Array<{
            asset: string;
            pay_to: string;
            network: string;
            amount: string;
          }>;
          description?: string;
        } = {};
    
        if (name) payload.name = name;
        if (pay_to && amount_usdc && network) {
          // Convert USD amount to USDC smallest unit (6 decimals)
          const amountInSmallestUnit = Math.round(parseFloat(amount_usdc) * 1_000_000).toString();
          payload.payment_requirements = [{
            asset: USDC_ADDRESSES[network],
            pay_to,
            network,
            amount: amountInSmallestUnit,
          }];
        }
        if (description) payload.description = description;
    
        const response = await fetch(url, {
          method: "PATCH",
          headers: getHeaders(),
          body: JSON.stringify(payload),
        });
    
        if (!response.ok) {
          throw new Error(
            `Failed to update payment instruction: ${response.status} ${response.statusText}`
          );
        }
    
        const data = await response.json();
        return successResponse(data);
      } catch (error) {
        return errorResponse(error);
      }
    }
  • The zod schema defining the input parameters for updatePaymentInstruction tool. It includes optional fields for id (required), name, pay_to, amount_usdc, network (enum: 'base' | 'base-sepolia'), and description.
    {
      id: z
        .string()
        .describe("The unique identifier of the payment instruction to update"),
      name: z.string().optional().describe("Updated name"),
      pay_to: z
        .string()
        .optional()
        .describe("Updated wallet address (0x...) to receive USDC payments"),
      amount_usdc: z
        .string()
        .optional()
        .describe("Updated price in USD as a string (e.g., '0.01' for 1 cent, '1.50' for $1.50)"),
      network: z
        .enum(["base", "base-sepolia"])
        .optional()
        .describe("Updated blockchain network"),
      description: z.string().optional().describe("Updated description"),
  • src/index.ts:1119-1193 (registration)
    The complete tool registration using server.tool() which registers the updatePaymentInstruction tool with its name, description, schema, and handler function.
    server.tool(
      "updatePaymentInstruction",
      "Update an existing x402 payment instruction. Currently supports USDC (6 decimals) on Base/Base Sepolia only.",
      {
        id: z
          .string()
          .describe("The unique identifier of the payment instruction to update"),
        name: z.string().optional().describe("Updated name"),
        pay_to: z
          .string()
          .optional()
          .describe("Updated wallet address (0x...) to receive USDC payments"),
        amount_usdc: z
          .string()
          .optional()
          .describe("Updated price in USD as a string (e.g., '0.01' for 1 cent, '1.50' for $1.50)"),
        network: z
          .enum(["base", "base-sepolia"])
          .optional()
          .describe("Updated blockchain network"),
        description: z.string().optional().describe("Updated description"),
      },
      async ({ id, name, pay_to, amount_usdc, network, description }) => {
        try {
          const url = `https://api.pinata.cloud/v3/x402/payment_instructions/${id}`;
    
          // USDC contract addresses
          const USDC_ADDRESSES: Record<string, string> = {
            "base": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
            "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
          };
    
          const payload: {
            name?: string;
            payment_requirements?: Array<{
              asset: string;
              pay_to: string;
              network: string;
              amount: string;
            }>;
            description?: string;
          } = {};
    
          if (name) payload.name = name;
          if (pay_to && amount_usdc && network) {
            // Convert USD amount to USDC smallest unit (6 decimals)
            const amountInSmallestUnit = Math.round(parseFloat(amount_usdc) * 1_000_000).toString();
            payload.payment_requirements = [{
              asset: USDC_ADDRESSES[network],
              pay_to,
              network,
              amount: amountInSmallestUnit,
            }];
          }
          if (description) payload.description = description;
    
          const response = await fetch(url, {
            method: "PATCH",
            headers: getHeaders(),
            body: JSON.stringify(payload),
          });
    
          if (!response.ok) {
            throw new Error(
              `Failed to update payment instruction: ${response.status} ${response.statusText}`
            );
          }
    
          const data = await response.json();
          return successResponse(data);
        } catch (error) {
          return errorResponse(error);
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions the update operation and current limitations, it doesn't address critical behavioral aspects: whether this requires specific permissions, if updates are reversible, what happens to unchanged fields, error conditions, or response format. For a mutation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It could potentially be more structured by separating limitations from the main purpose, but it contains no redundant information and every word serves a purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with 6 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address permission requirements, error handling, response format, or provide usage context. The current limitations mention is helpful but insufficient for the tool's complexity and mutation nature.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds minimal value beyond the schema - it mentions USDC and Base networks which relate to 'amount_usdc' and 'network' parameters, but doesn't provide additional semantic context beyond what's in the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Update') and resource ('existing x402 payment instruction'), providing specific scope about supported currencies (USDC) and networks (Base/Base Sepolia). However, it doesn't explicitly differentiate this from sibling tools like 'updateFile' or 'updateGroup' beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'createPaymentInstruction' or 'deletePaymentInstruction'. It mentions current limitations (USDC on Base networks only) but doesn't explain when this update operation is appropriate versus creating a new instruction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PinataCloud/pinata-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server