cotiv2-mcp
Version:
> A plug-and-play MCP tool server to **send COTI**, **transfer BEP-20 tokens**, **deploy tokens**, and **interact with smart contracts** on the **COTI v2 Network (COTI)** — built for **Claude Desktop**, **AI agents**, and **developers.**
44 lines (43 loc) • 1.55 kB
JavaScript
import { z } from "zod";
import { parseEther } from "viem";
import { getAccount, walletClient } from "../config.js";
import { buildTxUrl, checkTransactionHash } from "../util.js";
export function registerTransferNativeToken(server) {
server.tool("Send_COTI", "💎Transfer native token (COTI), Before execution, check the wallet information first", {
recipientAddress: z.string(),
amount: z.string(),
}, async ({ recipientAddress, amount }) => {
let txHash = undefined;
try {
const account = await getAccount();
txHash = await walletClient(account).sendTransaction({
to: recipientAddress,
value: parseEther(amount),
});
const txUrl = await checkTransactionHash(txHash);
return {
content: [
{
type: "text",
text: `Transaction sent successfully. ${txUrl}`,
url: txUrl,
},
],
};
}
catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
const txUrl = buildTxUrl(txHash);
return {
content: [
{
type: "text",
text: `transaction failed: ${errorMessage}`,
url: txUrl,
},
],
isError: true,
};
}
});
}