Skip to main content
Glama

evm_get_token_allowance

Check ERC20 token spending allowance from an owner to a spender to verify approvals before DeFi operations and determine whether re-approval is needed.

Instructions

Check ERC20 token spending allowance currently granted from owner to spender.

Returns the amount of tokens a spender is currently allowed to transfer on behalf of the owner. Used to verify approvals before DeFi operations and check if re-approval is needed.

CRITICAL RULES:

  • Returns current allowance amount (may be 0 if not approved)

  • Allowance decreases as spender uses it (check before each operation)

  • Allowance of 0 means no approval exists

  • Very large number (2^256-1) indicates unlimited approval

  • Read-only operation, no gas cost

PARAMETERS:

  • chain: EVM chain to query (required)

    • Allowances are chain-specific

    • Same owner/spender may have different allowances per chain

  • tokenAddress: ERC20 token contract address (required)

    • Format: 0x followed by 40 hex characters

    • Allowances are per-token

    • Examples: USDC, USDT, DAI, WETH

  • ownerAddress: Token owner address (required)

    • Address that granted the approval

    • Format: 0x followed by 40 hex characters

    • Must be address holding the tokens

  • spenderAddress: Spender address (required)

    • Address that can spend the tokens

    • Typically a smart contract (DEX, lending pool)

    • Format: 0x followed by 40 hex characters

EXAMPLES: ✅ Check USDC allowance for Uniswap on Polygon: {chain: "polygon", tokenAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", ownerAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb", spenderAddress: "0xE592427A0AEce92De3Edee1F18E0157C05861564"}

✅ Check allowance before DEX swap: {chain: "arbitrum", tokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", ownerAddress: "0x...", spenderAddress: "0xRouterAddress"}

✅ Verify approval was successful: {chain: "bsc", tokenAddress: "0x...", ownerAddress: "0x...", spenderAddress: "0x..."}

❌ Invalid - swapped owner and spender: {ownerAddress: "0xContractAddress", spenderAddress: "0xUserWallet"} // Backwards

❌ Invalid - wrong chain: {chain: "ethereum", tokenAddress: "0xPolygonUSDC..."} // Token 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 query success • chain: Chain queried • tokenAddress: Token contract checked • ownerAddress: Token owner • spenderAddress: Approved spender • allowance: Object with raw (string) and formatted (string) values • decimals: Token decimals used for formatting • isUnlimited: Boolean indicating if allowance is max uint256 • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Confusing owner and spender parameters (easy to swap)

  • Not checking allowance before assuming approval exists

  • Forgetting allowance decreases as it's spent

  • Not accounting for decimals when interpreting raw value

  • Assuming non-zero allowance means sufficient for operation

USE CASES:

  • Check if approval needed before DEX swap

  • Verify approval transaction succeeded

  • Monitor remaining allowance after partial usage

  • Audit approved spenders for security

  • Determine if re-approval required

ALLOWANCE LIFECYCLE:

  1. Initially 0 (no approval)

  2. Increased by evm_approve_token

  3. Decreased as spender transfers tokens

  4. Can be set back to 0 (revoke approval)

  5. Can be increased again (re-approve)

INTERPRETATION:

  • allowance = 0: No approval, must call evm_approve_token

  • allowance < needed: Insufficient, need to approve more

  • allowance ≥ needed: Sufficient, can proceed with operation

  • allowance = 2^256-1: Unlimited approval (never decreases)

SECURITY AUDITING: Check all your token allowances periodically:

  1. Query allowance for each token you hold

  2. Identify unknown or unused spender contracts

  3. Revoke suspicious or old approvals (approve amount "0")

BEFORE DEX SWAP: Always check allowance before attempting swap:

  1. Check allowance (this tool)

  2. If insufficient, approve tokens (evm_approve_token)

  3. Execute swap (evm_execute_swap)

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>",
      "ownerAddress": "<ownerAddress>",
      "spenderAddress": "<spenderAddress>"
    },
    "name": "evm_get_token_allowance"
  }
}

Input Schema

NameRequiredDescriptionDefault
chainYesEVM chain to query
ownerAddressYesToken owner address (0x...)
tokenAddressYesERC20 token contract address (0x...)
spenderAddressYesSpender address (0x...)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.4/5.0
Behavior5/5

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

With no annotations provided, the description carries the behavioral burden and does so thoroughly: it declares read-only/no gas, explains that allowance may be zero, decreases as spent, and that 2^256-1 means unlimited approval. It also documents output fields and common interpretation pitfalls.

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 rules are front-loaded, but the description is heavily bloated with unrelated chain/gas details, testnet notes, security auditing, and Linux-specific instructions. Much of that content does not help an agent invoke this specific tool and dilutes focus.

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?

For a read-only allowance query with no output schema, the description is complete: it covers parameters, examples, interpretation, lifecycle, output fields, and chain support. Nothing essential for correct invocation is missing.

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

Parameters4/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 four parameters. The description adds useful semantics beyond the schema: allowances are chain-specific and per-token, the owner must hold tokens, the spender is typically a contract, and it supplies address-format examples.

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: check the ERC20 token spending allowance granted from owner to spender. It also distinguishes this read-only query from approval actions by referencing evm_approve_token in the allowance lifecycle.

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?

It gives clear usage contexts: verify approvals before DeFi operations, check whether re-approval is needed, audit spenders, and follow a before-swap workflow. It names evm_approve_token as the follow-up for insufficient allowance, though it does not explicitly state when not to use this query.

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