Skip to main content
Glama

evm_approve_token

Approve ERC20 token spending allowances for DEX, lending, or other contracts so they can transfer tokens on your behalf; set amount to 0 to revoke.

Instructions

Approve ERC20 token spending allowance for a spender address (DEX, lending protocol, or other contract).

Grants permission for another address to spend your tokens on your behalf. Required before using DeFi protocols, DEX swaps, or any contract interaction that needs to transfer your tokens. Does NOT transfer tokens immediately.

CRITICAL RULES:

  • Approval does NOT transfer tokens - only grants permission

  • Required before DEX swaps, staking, lending, or any DeFi operations

  • "unlimited" approval is convenient but risky (allows spender to take all tokens)

  • Approval is per-token, per-spender, per-chain (must approve separately for each)

  • Can be revoked by approving amount "0"

  • Requires gas payment in native token

PARAMETERS:

  • chain: EVM chain to execute approval on (required)

    • Approval is chain-specific

    • Must have gas in native token on this chain

    • Token and spender must exist on same chain

  • tokenAddress: ERC20 token contract to approve (required)

    • Format: 0x followed by 40 hex characters

    • Token you want to allow spender to transfer

    • Examples: USDC, USDT, DAI, WETH

  • spenderAddress: Address receiving approval (required)

    • Typically a smart contract (DEX router, lending pool)

    • Format: 0x followed by 40 hex characters

    • Examples: Uniswap Router, Aave Pool, custom contract

    • VERIFY THIS ADDRESS - malicious spenders can steal tokens

  • amount: Approval amount (required)

    • Human-readable format: "100" = 100 tokens

    • Use "unlimited" or "max" for maximum approval (2^256-1)

    • Use "0" to revoke existing approval

    • Best practice: approve only amount needed

  • privateKey: Token owner's private key (required, KEEP SECRET)

    • Format: 0x followed by 64 hex characters

    • Must be key for address holding tokens

    • Never expose, share, or log this value

EXAMPLES: ✅ Approve 100 USDC for Uniswap on Polygon: {chain: "polygon", tokenAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", spenderAddress: "0xE592427A0AEce92De3Edee1F18E0157C05861564", amount: "100", privateKey: "0xac0974..."}

✅ Approve unlimited WETH for DEX (convenient but risky): {chain: "arbitrum", tokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", spenderAddress: "0x...", amount: "unlimited", privateKey: "0x..."}

✅ Revoke approval (security best practice): {chain: "bsc", tokenAddress: "0x...", spenderAddress: "0x...", amount: "0", privateKey: "0x..."}

❌ Invalid - approving EOA instead of contract: {chain: "polygon", spenderAddress: "0xPersonalWallet..."} // Personal wallets don't need approval

❌ Invalid - wrong chain for spender: {chain: "ethereum", spenderAddress: "0xPolygonOnlyRouter..."} // Spender not on Ethereum

SUPPORTED EVM CHAINS (7 networks): • ethereum (Sepolia) - EIP-1559 enabled, ~12s blocks, moderate gas costs • polygon (Amoy) - Low fees, fast finality (~2s), layer 2 • avalanche (Fuji C-Chain) - Sub-second finality, dynamic fees • bsc (BNB Testnet) - 3s blocks, low gas costs, Binance ecosystem • arbitrum (Sepolia) - Optimistic rollup, low fees, Ethereum security • base (Sepolia) - Coinbase layer 2, EIP-1559, low fees • worldchain (World Sepolia) - World Network testnet, EIP-1559

CRITICAL GAS CONSIDERATIONS:

  • Ethereum: High gas costs, use gas oracle for timing

  • Polygon/BSC: Very low gas, safe for frequent transactions

  • Arbitrum/Base: L2 optimizations, ~10-50x cheaper than Ethereum

  • Avalanche: Dynamic fees, can spike during congestion

  • Always check gas price before executing transactions

TESTNET TOKENS: All chains use testnet tokens with NO REAL VALUE. Faucets available for all supported networks.

OUTPUT STRUCTURE: • success: Boolean indicating approval success • chain: Chain where approval executed • transactionHash: Transaction hash for approval • tokenAddress: Token contract approved • spenderAddress: Address granted spending permission • amount: Amount approved (formatted) • owner: Token owner address (from privateKey) • gasUsed: Gas consumed by transaction • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Forgetting to approve before attempting DEX swap (will fail)

  • Approving personal wallet addresses (unnecessary)

  • Not revoking old approvals to unused contracts (security risk)

  • Approving wrong token or wrong spender

  • Unlimited approval to unaudited contracts (dangerous)

  • Not checking approval succeeded before next operation

USE CASES:

  • Enable DEX token swaps (approve router to spend token A)

  • Deposit tokens to lending protocols (approve pool contract)

  • Stake tokens in farming contracts (approve staking contract)

  • Bridge tokens across chains (approve bridge contract)

  • Interact with any DeFi protocol requiring token transfers

APPROVAL WORKFLOW:

  1. Identify spender address (DEX router, lending pool, etc.)

  2. Approve token for spender (this tool)

  3. Wait for approval transaction confirmation

  4. Execute main operation (swap, stake, lend)

  5. Optionally revoke approval after operation (security)

SECURITY CONSIDERATIONS:

  • Unlimited approvals are convenient but dangerous

  • Malicious contracts can drain approved tokens

  • Approve only verified, audited contracts

  • Revoke unused approvals periodically

  • Use exact amounts when possible (not unlimited)

  • Check spender address multiple times before approving

GAS COSTS:

  • Approval typically costs 45,000-50,000 gas

  • Ethereum Sepolia: ~0.001 ETH

  • Polygon: ~0.00005 POL (very cheap)

  • BSC: ~0.0001 BNB

  • Arbitrum/Base: ~0.0001 ETH

CHECKING EXISTING APPROVALS: Use evm_get_token_allowance to check current approval amount before approving again.

Running on Linux.

LINUX-SPECIFIC NOTES:

  • Package manager: apt (Ubuntu/Debian), yum (RHEL/CentOS), or pacman (Arch)

  • Python 3 is typically 'python3' command

  • GNU tools are standard

  • Use 'xdg-open' command to open files/applications

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "chain": "<chain>",
      "tokenAddress": "<tokenAddress>",
      "spenderAddress": "<spenderAddress>",
      "amount": "<amount>",
      "privateKey": "<privateKey>"
    },
    "name": "evm_approve_token"
  }
}

Input Schema

NameRequiredDescriptionDefault
chainYesEVM chain to execute on
amountYesApproval amount (use "unlimited" for max approval)
privateKeyYesToken owner private key (0x...)
tokenAddressYesERC20 token contract address (0x...)
spenderAddressYesSpender address to approve (0x...)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations supplied, the description carries the full burden and discloses key behavior: approval grants permission without transferring tokens, is per-token/per-spender/per-chain, can be revoked with amount 0, requires gas, and has security risks around unlimited approvals. It also documents output fields and common failure modes, giving an agent enough behavioral context to invoke it safely.

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

Conciseness2/5

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

The core purpose and critical rules are front-loaded, but the description is far too long and repeats gas, security, usage, and workflow details across multiple sections. It also includes completely irrelevant Linux package-manager notes that do not help an agent invoke evm_approve_token.

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

Completeness5/5

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

Given a five-parameter mutation tool with no annotations and no output schema, the description is complete enough for invocation: it covers purpose, parameters, supported chains, gas considerations, security, workflow, failure cases, and even an output structure. The irrelevant Linux section hurts conciseness but does not leave an operational gap for this tool.

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

Parameters5/5

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

Although the schema has 100% description coverage, those descriptions are minimal, and the tool description adds substantial meaning beyond them. It explains amount semantics including 'unlimited', 'max', and '0' for revocation, address formats, chain-specific execution requirements, privateKey secrecy, and concrete examples for each parameter.

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 states a specific verb and resource: approve an ERC20 token spending allowance for a spender address. It clearly distinguishes this from sibling operations such as evm_get_token_allowance and evm_approve_nft by focusing on ERC20 allowances rather than checking allowances or approving NFTs.

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?

It explicitly explains when to use the tool: before DeFi protocols, DEX swaps, staking, lending, bridging, or any contract interaction requiring token transfers. It also gives alternatives guidance by pointing to evm_get_token_allowance for checking existing approvals and provides invalid examples to prevent misuse.

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

Deploy Server

Other Tools