Skip to main content
Glama

generate_fungible_post_condition

Create mandatory SIP-010 fungible token transfer post-conditions for Stacks blockchain transactions, ensuring secure token operations by specifying conditions like amount equality or comparison.

Instructions

Generate a fungible token post-condition for SIP-010 tokens. Post-conditions are MANDATORY for all token transfers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesThe token amount in base units
assetNameYesThe token asset name (usually same as contract name)
conditionCodeYesThe condition type (usually 'equal' for exact transfers)
contractAddressYesThe token contract address
contractNameYesThe token contract name
principalYesThe Stacks address for the post-condition

Implementation Reference

  • The main handler for the 'generate_fungible_post_condition' tool. This is the execute function that generates TypeScript code, Clarity requirements, and security notes for fungible token post-conditions based on input parameters.
    export const generateFungiblePostConditionTool: Tool<undefined, typeof FungiblePostConditionScheme> = {
      name: "generate_fungible_post_condition",
      description: "Generate a fungible token post-condition for SIP-010 tokens. Post-conditions are MANDATORY for all token transfers.",
      parameters: FungiblePostConditionScheme,
      execute: async (args, context) => {
        try {
          await recordTelemetry({ action: "generate_fungible_post_condition" }, context);
          
          return `# Fungible Token Post-Condition
    
    ## Configuration
    - **Principal**: ${args.principal}
    - **Condition**: ${args.conditionCode}
    - **Amount**: ${args.amount} base units
    - **Asset**: ${args.contractAddress}.${args.contractName}.${args.assetName}
    
    ## TypeScript Implementation
    
    \`\`\`typescript
    import {
      makeStandardFungiblePostCondition,
      FungibleConditionCode,
      createAssetInfo
    } from '@stacks/transactions';
    
    const postCondition = makeStandardFungiblePostCondition(
      '${args.principal}',
      FungibleConditionCode.${args.conditionCode.charAt(0).toUpperCase() + args.conditionCode.slice(1).replace('_', '')},
      ${args.amount},
      createAssetInfo(
        '${args.contractAddress}',
        '${args.contractName}',
        '${args.assetName}'
      )
    );
    
    // Use in transaction
    const postConditions = [postCondition];
    
    await openContractCall({
      // ... other parameters
      postConditions,
      postConditionMode: PostConditionMode.Deny, // REQUIRED for security
    });
    \`\`\`
    
    ## Clarity Contract Requirements
    
    For this post-condition to work, the contract must use native asset functions:
    
    \`\`\`clarity
    ;; REQUIRED: Native fungible token definition
    (define-fungible-token ${args.assetName})
    
    ;; REQUIRED: Use ft-transfer? for transfers
    (define-public (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))
      (begin
        ;; ... validation logic ...
        (try! (ft-transfer? ${args.assetName} amount sender recipient))
        ;; ... rest of function ...
      )
    )
    \`\`\`
    
    ## Security Notes
    - ✅ This post-condition guarantees ${args.conditionCode === 'equal' ? 'exactly' : args.conditionCode} ${args.amount} tokens will be involved
    - ✅ Transaction will fail if condition is not met
    - ✅ Protects against unexpected token movements
    - ⚠️  Always use PostConditionMode.Deny for maximum security`;
          
        } catch (error) {
          return `❌ Failed to generate fungible post-condition: ${error}`;
        }
      },
    };
  • Zod schema defining the input parameters for the generate_fungible_post_condition tool: principal, conditionCode, amount, contractAddress, contractName, assetName.
    const FungiblePostConditionScheme = z.object({
      principal: z.string().describe("The Stacks address for the post-condition"),
      conditionCode: FungibleConditionCodeScheme.describe("The condition type (usually 'equal' for exact transfers)"),
      amount: z.number().describe("The token amount in base units"),
      contractAddress: z.string().describe("The token contract address"),
      contractName: z.string().describe("The token contract name"),
      assetName: z.string().describe("The token asset name (usually same as contract name)"),
    });
  • Registration of the generateFungiblePostConditionTool in the MCP server via server.addTool call.
    server.addTool(generateFungiblePostConditionTool);
  • Import of the generateFungiblePostConditionTool from its implementation file.
      generateFungiblePostConditionTool,
      generateNonFungiblePostConditionTool,
      generateSTXPostConditionTool,
      analyzeTransactionPostConditionsTool,
      generatePostConditionTemplateTool
    } from "./stacks_blockchain/security/post_conditions.js";
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states that post-conditions are 'MANDATORY' which is useful context, but doesn't describe what the tool actually produces (e.g., a structured object, a string, a transaction component), whether it validates inputs, what happens on failure, or any side effects. For a tool with 6 required parameters and no output schema, this leaves significant behavioral gaps.

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

Conciseness5/5

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

The description is extremely concise - just two sentences that directly state the purpose and usage context. Every word earns its place with zero waste. The structure is front-loaded with the core purpose followed by important context about mandatory usage.

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

Completeness3/5

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

Given the complexity (6 required parameters, no output schema, no annotations), the description provides minimal but essential context about purpose and mandatory usage. However, it doesn't explain what the tool outputs, how to use the generated post-condition, or provide examples. For a tool that generates a critical transaction component, more context would be helpful despite the good schema coverage.

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 with clear descriptions. The description doesn't add any additional parameter semantics beyond what's in the schema. The baseline score of 3 reflects adequate coverage through the schema alone, with no extra value from the description.

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 tool's purpose: 'Generate a fungible token post-condition for SIP-010 tokens.' It specifies the verb ('generate'), resource ('fungible token post-condition'), and domain context ('SIP-010 tokens'). However, it doesn't explicitly differentiate from sibling tools like 'generate_non_fungible_post_condition' or 'generate_stx_post_condition' beyond the 'fungible' qualifier.

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

Usage Guidelines4/5

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

The description provides clear usage context: 'Post-conditions are MANDATORY for all token transfers.' This indicates when to use the tool (for token transfers) and implies it's required rather than optional. However, it doesn't explicitly state when NOT to use it or name specific alternatives among sibling tools.

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/exponentlabshq/stacks-clarity-mcp'

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