Skip to main content
Glama
lordbasilaiassistant-sudo

base-gasless-deploy-mcp

transfer_tokens

Transfer ERC-20 tokens without paying gas fees using paymaster sponsorship, with automatic fallback to standard gas payments when sponsorship is unavailable.

Instructions

Transfer ERC-20 tokens gaslessly via paymaster. Falls back to normal gas if no paymaster. Requires DEPLOYER_PRIVATE_KEY (transfers FROM the deployer wallet).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address
toYesRecipient address
amountYesAmount in human units (e.g. '1000' for 1000 tokens)

Implementation Reference

  • The complete implementation of the 'transfer_tokens' tool handler, including input validation schema, transaction estimation, and execution logic.
    server.tool(
      "transfer_tokens",
      "Transfer ERC-20 tokens gaslessly via paymaster. Falls back to normal gas if no paymaster. Requires DEPLOYER_PRIVATE_KEY (transfers FROM the deployer wallet).",
      {
        token_address: z.string().describe("Token contract address"),
        to: z.string().describe("Recipient address"),
        amount: z.string().describe("Amount in human units (e.g. '1000' for 1000 tokens)"),
      },
      async ({ token_address, to, amount }) => {
        try {
          const signer = getSigner();
          const provider = getProvider();
          const token = new ethers.Contract(token_address, TOKEN_ABI, signer);
    
          // Get decimals
          const decimals = await token.decimals();
          const amountWei = ethers.parseUnits(amount, decimals);
    
          // Check balance
          const signerAddress = await signer.getAddress();
          const balance = await token.balanceOf(signerAddress);
          if (balance < amountWei) {
            return mcpError(
              `Insufficient balance. Have: ${ethers.formatUnits(balance, decimals)}, Need: ${amount}`
            );
          }
    
          // Estimate gas for savings calc
          const gasEstimate = await token.transfer.estimateGas(to, amountWei);
          const feeData = await provider.getFeeData();
          const gasPrice = feeData.gasPrice || 0n;
          const estimatedCostWei = gasEstimate * gasPrice;
    
          // Encode the transfer call
          const txData = token.interface.encodeFunctionData("transfer", [to, amountWei]);
          const txRequest: ethers.TransactionRequest = {
            to: token_address,
            data: txData,
          };
    
          const { receipt, usedPaymaster } = await sendTransaction(signer, txRequest);
          const actualGasCostWei = receipt.gasUsed * receipt.gasPrice;
    
          return mcpResult({
            success: true,
            token_address,
            from: signerAddress,
            to,
            amount,
            decimals: Number(decimals),
            gasless: usedPaymaster,
            gas_used: receipt.gasUsed.toString(),
            gas_cost_eth: usedPaymaster ? "0 (sponsored)" : ethers.formatEther(actualGasCostWei),
            gas_saved_eth: usedPaymaster ? ethers.formatEther(estimatedCostWei) : "0",
            tx_hash: receipt.hash,
            block_number: receipt.blockNumber,
            explorer: `https://basescan.org/tx/${receipt.hash}`,
          });
        } catch (err: unknown) {
          const message = err instanceof Error ? err.message : String(err);
          return mcpError(`Transfer failed: ${message}`);
        }
      }
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 traits: the gasless mechanism via paymaster, fallback to normal gas, and the requirement for DEPLOYER_PRIVATE_KEY (indicating auth needs and that transfers are from a specific wallet). It lacks details on rate limits, error handling, or what happens if paymaster fails, but covers essential operational context adequately.

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 front-loaded with the core purpose in the first clause, followed by key behavioral details in two concise sentences. Every sentence adds value: the first defines the action and mechanism, the second covers fallback and prerequisites, with no wasted words or redundancy.

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?

Given the tool's complexity (token transfer with gasless logic), no annotations, and no output schema, the description is mostly complete. It covers the main action, mechanism, fallback, and auth needs, but lacks details on return values, error cases, or specific behavioral outcomes (e.g., transaction hash or confirmation), which could be beneficial for an agent.

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 three parameters (token_address, to, amount) with clear descriptions. The description does not add any parameter-specific details beyond what the schema provides, such as format examples or constraints, meeting the baseline for high schema coverage.

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 specific action ('transfer ERC-20 tokens gaslessly via paymaster') and resource (tokens), distinguishing it from siblings like deploy_gasless_token (creation), estimate_gas_savings (estimation), get_token_info (query), and list_deployed_tokens (listing). It specifies the fallback behavior and source wallet, making the purpose explicit and differentiated.

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 context for when to use this tool (for gasless token transfers with a fallback) and mentions a prerequisite (DEPLOYER_PRIVATE_KEY). However, it does not explicitly state when not to use it or name alternatives among siblings, such as using estimate_gas_savings for pre-transfer checks or get_token_info for token details, leaving some guidance implicit.

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/lordbasilaiassistant-sudo/base-gasless-deploy-mcp'

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