Skip to main content
Glama

evm_send_contract_transaction

Broadcasts a gas-paid transaction to execute a smart contract write function, enabling token transfers, staking, swaps, and NFT minting on supported EVM chains.

Instructions

Send transaction to smart contract to execute write function (modifies state, requires gas).

Broadcasts transaction to blockchain that modifies contract state. Used for token transfers, staking, swaps, NFT minting, and any operation that changes on-chain data. Transaction must be confirmed by network.

CRITICAL RULES:

  • Modifies blockchain state (write operation)

  • Requires gas payment in native token

  • Transaction is irreversible once confirmed

  • Must have correct ABI and function signature

  • Parameters must match exactly (type and order)

  • Private key grants transaction signing authority

  • Optional value parameter to send native tokens with call

PARAMETERS:

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

    • Must have gas in native token

    • Gas costs vary by chain and function complexity

  • contractAddress: Smart contract address (required)

    • Format: 0x followed by 40 hex characters

    • Must be deployed contract

    • Examples: DEX routers, NFT contracts, staking pools

  • abi: Contract Application Binary Interface (required)

    • JSON array defining contract interface

    • Must include function being called

    • Get from block explorer or project docs

    • Defines function signature for encoding

  • functionName: Name of function to execute (required)

    • Must be state-changing function (not view/pure)

    • Case-sensitive, exact match required

    • Examples: "transfer", "approve", "swap", "stake"

  • params: Function parameters array (optional)

    • Must match function signature exactly

    • Correct types and order critical

    • Empty array [] if no parameters

    • Examples: ["0xAddress", "1000"], []

  • value: Native token amount to send (optional)

    • In ether units (e.g., "0.1" = 0.1 ETH/POL/etc.)

    • Used for payable functions only

    • Most functions don't need this (default: "0")

    • Examples: "0.1", "1.5", "0"

  • privateKey: Transaction signer's private key (required, KEEP SECRET)

    • Format: 0x followed by 64 hex characters

    • Must have gas for transaction

    • Grants full signing authority

    • Never expose, share, or log this value

EXAMPLES: ✅ Stake tokens in DeFi protocol (Polygon): {chain: "polygon", contractAddress: "0xStakingContract...", abi: [...], functionName: "stake", params: ["1000000000000000000"], value: "0", privateKey: "0xac0974..."}

✅ Execute DEX swap (Arbitrum): {chain: "arbitrum", contractAddress: "0xRouterV2...", abi: [...], functionName: "swapExactTokensForTokens", params: ["1000000", "950000", ["0xToken0", "0xToken1"], "0xRecipient", "1234567890"], privateKey: "0x..."}

✅ Mint NFT with payment (Ethereum): {chain: "ethereum", contractAddress: "0xNFT...", abi: [...], functionName: "mint", params: ["1"], value: "0.05", privateKey: "0x..."}

❌ Invalid - insufficient gas: {chain: "ethereum", ...} // No ETH for gas

❌ Invalid - wrong parameter types: {params: [1000, "0xAddress"]} // Number instead of string

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 transaction success • chain: Chain where transaction executed • transactionHash: Transaction hash for tracking • contractAddress: Contract called • functionName: Function executed • from: Sender address (derived from privateKey) • gasUsed: Gas consumed by transaction • blockNumber: Block containing transaction • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Not having sufficient gas for transaction

  • Wrong ABI (function signature mismatch)

  • Incorrect parameter types or order

  • Forgetting to approve tokens before swap/transfer

  • Using view/pure functions (use evm_call_contract instead)

  • Not waiting for transaction confirmation

USE CASES:

  • Execute DEX token swaps

  • Stake tokens in DeFi protocols

  • Mint or transfer NFTs

  • Claim rewards from contracts

  • Interact with lending protocols

  • Call custom contract functions

TRANSACTION FLOW:

  1. Check gas balance (evm_get_balance)

  2. Approve tokens if needed (evm_approve_token)

  3. Encode function call with ABI

  4. Sign transaction with private key

  5. Broadcast to network

  6. Wait for confirmation

GAS ESTIMATION:

  • Simple functions: 50,000-100,000 gas

  • Complex functions (swaps): 150,000-300,000 gas

  • Very complex (multi-operation): 300,000-500,000 gas

  • Use evm_estimate_gas before executing

PAYABLE FUNCTIONS: Functions that accept native tokens (ETH/POL):

  • Specify value parameter in ether units

  • Contract must mark function as "payable"

  • Common in: NFT minting, deposits, purchases

  • Example: Mint NFT for 0.05 ETH

NON-PAYABLE FUNCTIONS: Most functions don't accept native tokens:

  • Leave value as "0" or omit

  • Use token approvals instead (ERC20)

  • Attempting to send value will fail

GETTING CONTRACT ABI:

  1. Block explorer (Etherscan/PolygonScan) - verified contracts

  2. Project GitHub repository

  3. Project documentation

  4. npm packages (@uniswap/v2-periphery)

SECURITY NOTES:

  • Verify contract address carefully (phishing risk)

  • Check function name and parameters

  • Test with small amounts first

  • Understand what function does before calling

  • Monitor transaction on block explorer

  • Keep private keys secure

ABI REQUIREMENT: Full function ABI entry needed: { "name": "transfer", "type": "function", "stateMutability": "nonpayable", "inputs": [ {"name": "recipient", "type": "address"}, {"name": "amount", "type": "uint256"} ], "outputs": [{"name": "", "type": "bool"}] }

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>",
      "contractAddress": "<contractAddress>",
      "abi": "<abi>",
      "functionName": "<functionName>",
      "privateKey": "<privateKey>"
    },
    "name": "evm_send_contract_transaction"
  }
}

Input Schema

NameRequiredDescriptionDefault
abiYesContract ABI (JSON array)
chainYesEVM chain to execute on
valueNoETH amount to send with transaction (optional, in ether)
paramsNoFunction parameters (optional)
privateKeyYesPrivate key to sign transaction (0x...)
functionNameYesFunction name to call
contractAddressYesSmart contract address (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 does so: it discloses irreversibility, gas payment requirements, that the private key grants full signing authority, payable vs non-payable failure behavior, expected gas ranges, and a full OUTPUT STRUCTURE (success, transactionHash, gasUsed, blockNumber). Failure modes ('Attempting to send value will fail', insufficient gas) are spelled out rather than left to inference.

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 critical constraint (write operation, gas, irreversibility) is front-loaded, but the remainder is heavily redundant: gas estimates appear in GAS ESTIMATION, CRITICAL GAS CONSIDERATIONS, and the chain list; use cases appear in USE CASES, COMMON MISTAKES, and the intro. It also contains an unrelated 'Running on Linux / apt / xdg-open' block that has nothing to do with an EVM transaction tool and should be removed.

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 high-stakes, 7-parameter, irreversible mutation with no annotations and no output schema, the description covers signing, encoding, prerequisites, supported chains, gas behavior, verification steps, and a documented return shape. Nothing an agent needs in order to invoke it safely is missing.

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?

Schema coverage is 100% so the baseline is 3, but the description adds substantial meaning beyond it: value is in ether units with examples, params must be an empty array when the function takes none, functionName is case-sensitive and must be state-changing, contractAddress/privateKey hex formats, and a full ABI entry example showing the required shape. That is real semantic enrichment, not restatement.

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?

Opens with a specific verb+resource ('Send transaction to smart contract to execute write function') and immediately bounds scope with '(modifies state, requires gas)'. It explicitly distinguishes itself from the read-only sibling by warning 'Using view/pure functions (use evm_call_contract instead)', so an agent can route correctly without opening another schema.

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?

Provides explicit when-to-use (token transfers, staking, swaps, NFT minting, claiming rewards), prerequisites (gas balance, token approvals), and a numbered TRANSACTION FLOW that names the alternative tools (evm_get_balance, evm_approve_token, evm_estimate_gas) and when each precedes this call. It also states when NOT to use it (view/pure functions) and names the substitute.

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