Skip to main content
Glama

call

Simulate and execute blockchain transactions instantly without network submission. Use contract addresses and encoded data to test calls securely via MetaMask MCP, ensuring private key safety during operations.

Instructions

Executing a new message call immediately without submitting a transaction to the network.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesA contract hashed method call with encoded args.
toYesThe contract address or recipient.
valueNoValue (in wei) sent with this transaction.

Implementation Reference

  • The execute handler for the 'call' tool. It calls wagmi's 'call' function with the provided args (to, data, value), returns the result hash on success, or error message on failure.
    execute: async (args) => { try { const result = await call(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify({ hash: result, }), }, ], }; } catch (error) { if (error instanceof TransactionExecutionError) { return { content: [ { type: "text", text: error.cause.message, }, ], }; } return { content: [ { type: "text", text: (error as Error).message, }, ], }; } },
  • The input schema (parameters) for the 'call' tool defining 'to', 'data', and optional 'value'.
    parameters: z.object({ to: Address.describe("The contract address or recipient."), data: Calldata.describe("A contract hashed method call with encoded args."), value: z.coerce.bigint().optional().describe("Value (in wei) sent with this transaction."), }),
  • The server.addTool call that registers the 'call' tool, including name, description, schema, and handler.
    server.addTool({ name: "call", description: "Executing a new message call immediately without submitting a transaction to the network.", parameters: z.object({ to: Address.describe("The contract address or recipient."), data: Calldata.describe("A contract hashed method call with encoded args."), value: z.coerce.bigint().optional().describe("Value (in wei) sent with this transaction."), }), execute: async (args) => { try { const result = await call(wagmiConfig, args); return { content: [ { type: "text", text: JSONStringify({ hash: result, }), }, ], }; } catch (error) { if (error instanceof TransactionExecutionError) { return { content: [ { type: "text", text: error.cause.message, }, ], }; } return { content: [ { type: "text", text: (error as Error).message, }, ], }; } }, });
  • Invocation of registerCallTools within the main registerTools function to register the 'call' tool.
    registerCallTools(server, wagmiConfig);
  • Export of the call tool registration from index.ts, allowing import in register-tools.ts.
    export * from "./call";

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/Xiawpohr/metamask-mcp'

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