Skip to main content
Glama

zora_trade_coin

Swap ETH or ERC20 tokens for Zora Coins on Base mainnet using permit2 for ERC20 transactions with private key authentication.

Instructions

Swap ETH or ERC20 for a coin (or back). Uses permit2 for ERC20 where supported. Requires PRIVATE_KEY (EOA).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sellTypeYes
sellAddressNo
sellDecimalsNo
buyTypeYes
buyAddressNo
amountYes
slippageNo
recipientNo
senderNo

Implementation Reference

  • Handler function for trading coins: parses inputs, constructs trade parameters, calls CoinsSDK.tradeCoin, and returns receipt as JSON.
    async (args) => { ensureWallet(); const { sellType, sellAddress, sellDecimals, buyType, buyAddress, amount, slippage, recipient, sender, } = args; const amountIn = sellType === "eth" ? parseEther(amount) : parseUnits( amount, typeof sellDecimals === "number" ? sellDecimals : 18 ); const tradeParameters: any = { sell: sellType === "eth" ? { type: "eth" } : { type: "erc20", address: sellAddress }, buy: buyType === "eth" ? { type: "eth" } : { type: "erc20", address: buyAddress }, amountIn, slippage: typeof slippage === "number" ? slippage : 0.05, sender: sender || account!.address, recipient: recipient || account!.address, }; const receipt = await CoinsSDK.tradeCoin({ tradeParameters, walletClient: walletClient!, account: account!, publicClient, }); return { content: [{ type: "text", text: json(receipt) }] }; }
  • Tool schema defining title, description, and Zod inputSchema for trade parameters (sell/buy types, amounts, slippage, etc.).
    { title: "Trade coin", description: "Swap ETH or ERC20 for a coin (or back). Uses permit2 for ERC20 where supported. Requires PRIVATE_KEY (EOA).", inputSchema: { sellType: z.enum(["eth", "erc20"]), sellAddress: z.string().optional(), // required if sellType = erc20 sellDecimals: z.number().int().min(0).max(36).optional(), // required if sellType = erc20 buyType: z.enum(["eth", "erc20"]), buyAddress: z.string().optional(), // required if buyType = erc20 amount: z.string().min(1), // human-readable, e.g., "0.001" ETH or "4" USDC slippage: z.number().min(0).max(0.99).default(0.05).optional(), recipient: z.string().optional(), sender: z.string().optional(), },
  • src/index.ts:432-490 (registration)
    McpServer.registerTool call registering the zora_trade_coin tool with its schema and handler.
    server.registerTool( "zora_trade_coin", { title: "Trade coin", description: "Swap ETH or ERC20 for a coin (or back). Uses permit2 for ERC20 where supported. Requires PRIVATE_KEY (EOA).", inputSchema: { sellType: z.enum(["eth", "erc20"]), sellAddress: z.string().optional(), // required if sellType = erc20 sellDecimals: z.number().int().min(0).max(36).optional(), // required if sellType = erc20 buyType: z.enum(["eth", "erc20"]), buyAddress: z.string().optional(), // required if buyType = erc20 amount: z.string().min(1), // human-readable, e.g., "0.001" ETH or "4" USDC slippage: z.number().min(0).max(0.99).default(0.05).optional(), recipient: z.string().optional(), sender: z.string().optional(), }, }, async (args) => { ensureWallet(); const { sellType, sellAddress, sellDecimals, buyType, buyAddress, amount, slippage, recipient, sender, } = args; const amountIn = sellType === "eth" ? parseEther(amount) : parseUnits( amount, typeof sellDecimals === "number" ? sellDecimals : 18 ); const tradeParameters: any = { sell: sellType === "eth" ? { type: "eth" } : { type: "erc20", address: sellAddress }, buy: buyType === "eth" ? { type: "eth" } : { type: "erc20", address: buyAddress }, amountIn, slippage: typeof slippage === "number" ? slippage : 0.05, sender: sender || account!.address, recipient: recipient || account!.address, }; const receipt = await CoinsSDK.tradeCoin({ tradeParameters, walletClient: walletClient!, account: account!, publicClient, }); return { content: [{ type: "text", text: json(receipt) }] }; } );

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/r4topunk/zora-coins-mcp-server'

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