Skip to main content
Glama

send_payment

Send ETH or ERC20 tokens from an AI agent wallet, executing immediately within limits or queuing for approval when exceeding thresholds. Check spend limits first to manage transactions effectively.

Instructions

Send ETH or ERC20 tokens from the Agent Wallet. If the amount is within the configured spend limits, it executes immediately and returns the tx hash. If it exceeds limits, the transaction is queued for owner approval (use queue_approval to manage). Always check spend limits first with check_spend_limit to avoid surprises.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesRecipient wallet address (0x-prefixed)
amount_ethYesAmount in ETH (or token units). E.g. "0.001" for 0.001 ETH, "1.5" for 1.5 USDC
tokenNoERC20 token address. Omit for native ETH.
token_decimalsNoToken decimals (default 18 for ETH, 6 for USDC)
memoNoOptional memo for this payment (not stored on-chain)

Implementation Reference

  • The handler function 'handleSendPayment' executes the payment logic, determining if it is a native ETH or ERC20 token transfer and then using the appropriate SDK method.
    export async function handleSendPayment(
      input: SendPaymentInput
    ): Promise<{ content: Array<{ type: 'text'; text: string }>; isError?: boolean }> {
      try {
        const wallet = getWallet();
        const config = getConfig();
    
        // Validate recipient address
        if (!input.to.startsWith('0x') || input.to.length !== 42) {
          throw new Error(
            `Invalid recipient address: "${input.to}". Must be a 0x-prefixed 42-character hex string.`
          );
        }
        const toAddress = input.to as Address;
    
        // Parse amount
        const amountCheck = parseFloat(input.amount_eth);
        if (isNaN(amountCheck) || amountCheck <= 0) {
          throw new Error(`Invalid amount: "${input.amount_eth}". Must be a positive number.`);
        }
    
        const decimals = input.token_decimals ?? 18;
        const amountWei = parseTokenAmount(input.amount_eth, decimals);
    
        const isNativeEth = !input.token || input.token === NATIVE_TOKEN || input.token === '0x0000000000000000000000000000000000000000';
        const tokenAddress = isNativeEth ? NATIVE_TOKEN : (input.token as Address);
        const tokenLabel = isNativeEth ? 'ETH' : input.token ?? 'ETH';
    
        let txHash: string;
    
        if (isNativeEth) {
          // Native ETH transfer via agentExecute
          const result = await agentExecute(wallet, {
            to: toAddress,
            value: amountWei,
          });
          txHash = result.txHash;
        } else {
          // ERC20 transfer via agentTransferToken
          txHash = await agentTransferToken(wallet, {
            token: tokenAddress,
            to: toAddress,
            amount: amountWei,
          });
        }
    
        const explorerUrl = explorerTxUrl(txHash as `0x${string}`, config.chainId);
        const memoLine = input.memo ? `\n📝 Memo: ${input.memo}` : '';
    
        return {
          content: [
            textContent(
              `✅ **Payment Sent**\n\n` +
              `  To:      ${toAddress}\n` +
              `  Amount:  ${input.amount_eth} ${tokenLabel}\n` +
              `  Token:   ${tokenLabel}\n` +
              `  Network: ${chainName(config.chainId)}\n` +
              `  TX Hash: ${txHash}\n` +
              `  🔗 ${explorerUrl}` +
              memoLine + '\n\n' +
              `ℹ️  If the transaction was over-limit, it was queued for owner approval.\n` +
              `   Use queue_approval (action="list") to check pending transactions.`
            ),
          ],
        };
      } catch (error: unknown) {
        return {
          content: [textContent(formatError(error, 'send_payment'))],
          isError: true,
        };
      }
    }
  • The Zod schema 'SendPaymentSchema' defines the input structure and validation for the 'send_payment' tool.
    export const SendPaymentSchema = z.object({
      to: z
        .string()
        .describe('Recipient address (0x-prefixed, checksummed or lowercase)'),
      amount_eth: z
        .string()
        .describe(
          'Amount to send, expressed in ETH (e.g. "0.001"). ' +
          'For ERC20 tokens, this is the human-readable amount (e.g. "1.5" for 1.5 USDC). ' +
          'Use the token_decimals parameter to control precision.'
        ),
      token: z
        .string()
        .optional()
        .describe(
          'ERC20 token contract address. ' +
          'Omit or use "0x0000000000000000000000000000000000000000" for native ETH.'
        ),
      token_decimals: z
        .number()
        .int()
        .min(0)
        .max(18)
        .optional()
        .default(18)
        .describe('Token decimal places (default: 18 for ETH; use 6 for USDC).'),
      memo: z
        .string()
        .max(200)
        .optional()
        .describe('Optional memo/note for this payment (logged locally, not on-chain).'),
    });
  • The 'sendPaymentTool' object exports the metadata, description, and input schema expected by the MCP protocol to register the 'send_payment' tool.
    export const sendPaymentTool = {
      name: 'send_payment',
      description:
        'Send ETH or ERC20 tokens from the Agent Wallet. ' +
        'If the amount is within the configured spend limits, it executes immediately and returns the tx hash. ' +
        'If it exceeds limits, the transaction is queued for owner approval (use queue_approval to manage). ' +
        'Always check spend limits first with check_spend_limit to avoid surprises.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          to: {
            type: 'string',
            description: 'Recipient wallet address (0x-prefixed)',
          },
          amount_eth: {
            type: 'string',
            description: 'Amount in ETH (or token units). E.g. "0.001" for 0.001 ETH, "1.5" for 1.5 USDC',
          },
          token: {
            type: 'string',
            description: 'ERC20 token address. Omit for native ETH.',
          },
          token_decimals: {
            type: 'number',
            description: 'Token decimals (default 18 for ETH, 6 for USDC)',
            default: 18,
          },
          memo: {
            type: 'string',
            description: 'Optional memo for this payment (not stored on-chain)',
            maxLength: 200,
          },
        },
        required: ['to', 'amount_eth'],
      },
    };
  • The helper function 'parseTokenAmount' converts a human-readable token amount string into a BigInt representation based on the token's decimal count.
    export function parseTokenAmount(amount: string, decimals: number): bigint {
      const trimmed = amount.trim();
      if (!trimmed || isNaN(Number(trimmed))) {
        throw new Error(`Invalid amount: "${amount}"`);
      }
    
      const [intPart, fracPart = ''] = trimmed.split('.');
      const fracTrimmed = fracPart.slice(0, decimals).padEnd(decimals, '0');
      const intStr = (intPart ?? '0') + fracTrimmed;
    
      return BigInt(intStr);
    }
Behavior4/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 effectively describes key behaviors: immediate execution within limits, queuing for owner approval if exceeding limits, and the need to check limits first. It doesn't cover rate limits or auth needs, but provides substantial operational context.

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 efficiently structured with three sentences: purpose, conditional behavior, and prerequisite action. Every sentence adds value—no wasted words—and it's front-loaded with the core functionality.

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

Completeness4/5

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

For a payment tool with no annotations and no output schema, the description does well by explaining the execution flow (immediate vs. queued) and linking to related tools. It could mention return values (tx hash) more explicitly, but overall it's quite complete given the context.

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 parameters thoroughly. The description doesn't add any parameter-specific semantics beyond what's in the schema (e.g., it doesn't explain token address format or memo usage further). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose5/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: 'Send ETH or ERC20 tokens from the Agent Wallet.' It specifies the action (send), resources (ETH/ERC20 tokens), and source (Agent Wallet), distinguishing it from siblings like check_spend_limit or get_transaction_history.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool vs. alternatives: 'Always check spend limits first with check_spend_limit to avoid surprises.' It also explains what happens if limits are exceeded (queued for approval, use queue_approval to manage), offering clear context and exclusions.

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/up2itnow0822/claw-pay-mcp'

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