Skip to main content
Glama

send-transaction

Execute blockchain transactions by specifying recipient addresses, values, and data payloads to interact securely with decentralized networks.

Instructions

Send transactions to networks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYes
valueNo
dataNo

Implementation Reference

  • The execute handler for the 'send-transaction' tool. It sends a transaction using wagmi/core's sendTransaction with parameters to, value (optional), data (optional). Returns the transaction hash in JSON or an error message in MCP content format, handling TransactionExecutionError specifically.
    execute: async (args) => { try { const to = args.to as Address const value = args.value ? BigInt(args.value) : undefined const data = args.data as Address const result = await sendTransaction(wagmiConfig, { to, value, data, }) 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, } ] } } },
  • Zod input schema defining the parameters for the send-transaction tool: 'to' (required string), 'value' (optional coercible number), 'data' (optional string).
    parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string().optional(), }),
  • The registration function that defines and adds the 'send-transaction' tool to the FastMCP server instance, including name, description, schema, and handler.
    export function registerSendTransactionTools(server: FastMCP): void { server.addTool({ name: "send-transaction", description: "Send transactions to networks", parameters: z.object({ to: z.string(), value: z.coerce.number().optional(), data: z.string().optional(), }), execute: async (args) => { try { const to = args.to as Address const value = args.value ? BigInt(args.value) : undefined const data = args.data as Address const result = await sendTransaction(wagmiConfig, { to, value, data, }) 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 the registerSendTransactionTools function during server initialization to register the tool on the main FastMCP server.
    registerSendTransactionTools(server);

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/mcpilot'

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