send-mon-transaction
Initiate MON token transfers on the Monad testnet by specifying recipient addresses and transaction amounts using this MCP server tool.
Instructions
Send MON transaction on Monad testnet
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount of MON to send | |
| to | Yes | Recipient address |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"amount": {
"description": "Amount of MON to send",
"type": "string"
},
"to": {
"description": "Recipient address",
"type": "string"
}
},
"required": [
"to",
"amount"
],
"type": "object"
}
Implementation Reference
- src/tools/wallet/transfer.ts:21-50 (handler)The core handler function that executes the tool: creates wallet client, sends transaction to recipient with parsed ether amount, returns success with tx hash or error message.async ({ to, amount }) => { try { // Create wallet client const client = await createWallet(); // Send transaction const hash = await client.sendTransaction({ to: to as `0x${string}`, value: parseEther(amount), }); return { content: [ { type: "text", text: `Transaction sent successfully! Hash: ${hash}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to send transaction. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
- src/tools/wallet/transfer.ts:17-20 (schema)Input validation schema using Zod for recipient address and MON amount.{ to: z.string().describe("Recipient address"), amount: z.string().describe("Amount of MON to send"), },
- src/tools/wallet/transfer.ts:13-52 (registration)Registers the send-mon-transaction tool on the MCP server with name, description, schema, and handler function.export function sendMonProvider(server: McpServer) { server.tool( "send-mon-transaction", "Send MON transaction on Monad testnet", { to: z.string().describe("Recipient address"), amount: z.string().describe("Amount of MON to send"), }, async ({ to, amount }) => { try { // Create wallet client const client = await createWallet(); // Send transaction const hash = await client.sendTransaction({ to: to as `0x${string}`, value: parseEther(amount), }); return { content: [ { type: "text", text: `Transaction sent successfully! Hash: ${hash}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to send transaction. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); }
- src/config/server.ts:47-55 (helper)Utility function to create a configured wallet client for Monad testnet from environment private key, used by the handler.export async function createWallet() { const privateKey = process.env.PRIVATE_KEY; if (!privateKey) { throw new Error('PRIVATE_KEY environment variable is not set'); } const account = privateKeyToAccount(privateKey as `0x${string}`); const client = createWalletClient({ account, chain: monadTestnet, transport: http() }); return client; }
- src/index.ts:24-24 (registration)Top-level call to walletProvider during server initialization, which chains to sendMonProvider registration.walletProvider(server);