Skip to main content
Glama

deploy_coin

Create and deploy custom tokens on the Aptos blockchain to enable minting, transfers, and management of new coin types.

Instructions

Deploy a new custom coin/token on Aptos blockchain. This creates a new coin type that can be minted, transferred, and managed. Returns the coin type identifier and deployment transaction details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName of the coin (e.g., 'My Token')
symbolYesSymbol of the coin (e.g., 'MTK')
decimalsNoNumber of decimal places for the coin (typically 6 or 8)
icon_urlNoURL to the coin icon/logo (optional)
project_urlNoURL to the project website (optional)
max_gas_amountNoMaximum gas amount for the transaction (optional)

Implementation Reference

  • Main handler function for the deploy_coin tool. Validates input arguments and orchestrates the deployment by calling performDeployCoin.
    export async function deployCoinHandler(args: Record<string, any> | undefined) { if (!isDeployCoinArgs(args)) { throw new Error("Invalid arguments for deploy_coin"); } const { name, symbol, decimals = 8, icon_url, project_url, max_gas_amount = 5000 } = args; try { const results = await performDeployCoin( name, symbol, decimals, icon_url, project_url, max_gas_amount ); return { content: [{ type: "text", text: results }], isError: false, }; } catch (error) { return { content: [ { type: "text", text: `Error deploying coin: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Tool definition object for deploy_coin, including input schema with properties for name, symbol, decimals, etc.
    export const DEPLOY_COIN: Tool = { name: "deploy_coin", description: "Deploy a new custom coin/token on Aptos blockchain. This creates a new coin type that can be minted, transferred, and managed. Returns the coin type identifier and deployment transaction details.", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the coin (e.g., 'My Token')", }, symbol: { type: "string", description: "Symbol of the coin (e.g., 'MTK')", }, decimals: { type: "number", description: "Number of decimal places for the coin (typically 6 or 8)", default: 8, minimum: 0, maximum: 32, }, icon_url: { type: "string", description: "URL to the coin icon/logo (optional)", }, project_url: { type: "string", description: "URL to the project website (optional)", }, max_gas_amount: { type: "number", description: "Maximum gas amount for the transaction (optional)", default: 5000, }, }, required: ["name", "symbol"], }, };
  • src/index.ts:130-131 (registration)
    Registration and dispatch of the deploy_coin handler in the main tool call switch statement.
    case "deploy_coin": return await deployCoinHandler(args);
  • Core helper function that performs the actual coin deployment: validates params, builds transaction using managed_coin::initialize, signs, submits, waits for confirmation, and formats results with coin type.
    export async function performDeployCoin( name: string, symbol: string, decimals: number = 8, iconUrl?: string, projectUrl?: string, maxGasAmount: number = 5000 ): Promise<string> { try { const aptos = getAptosClient(); const deployerAccount = getDefaultAccount(); const deployerAddress = deployerAccount.accountAddress.toString(); // Validate inputs if (!name || name.trim().length === 0) { throw new Error("Coin name cannot be empty"); } if (!symbol || symbol.trim().length === 0) { throw new Error("Coin symbol cannot be empty"); } if (symbol.length > 10) { throw new Error("Coin symbol should be 10 characters or less"); } if (decimals < 0 || decimals > 32) { throw new Error("Decimals must be between 0 and 32"); } // Create the coin deployment transaction const transaction = await aptos.transaction.build.simple({ sender: deployerAccount.accountAddress, data: { function: "0x1::managed_coin::initialize", typeArguments: [], functionArguments: [ name.trim(), symbol.trim().toUpperCase(), decimals, false, // monitor_supply ], }, options: { maxGasAmount, }, }); // Sign and submit the transaction const committedTxn = await aptos.signAndSubmitTransaction({ signer: deployerAccount, transaction, }); // Wait for transaction confirmation const executedTxn = await aptos.waitForTransaction({ transactionHash: committedTxn.hash, }); // Generate the coin type identifier const coinType = `${deployerAddress}::coin::T`; let result = `šŸŖ™ Coin Deployment Successful! Coin Details: Name: ${name} Symbol: ${symbol} Decimals: ${decimals} Deployer: ${formatAddress(deployerAddress)} Blockchain Information: Coin Type: ${coinType} Transaction Hash: ${committedTxn.hash} Gas Used: ${executedTxn.gas_used} Status: ${executedTxn.success ? 'Success' : 'Failed'}`; if (iconUrl) { result += ` Icon URL: ${iconUrl}`; } if (projectUrl) { result += ` Project URL: ${projectUrl}`; } result += ` šŸ“‹ Next Steps: 1. Mint coins using the mint_coin tool with coin type: ${coinType} 2. Register the coin for accounts that want to receive it 3. Transfer coins using the transfer_coin tool āš ļø Important Notes: - Save the coin type identifier: ${coinType} - Only the deployer (${formatAddress(deployerAddress)}) can mint new coins - Recipients must register for this coin type before receiving transfers - This coin follows the Aptos Managed Coin standard āœ… Your custom coin is now live on Aptos ${getCurrentNetwork()}!`; return result; } catch (error) { console.error('Error deploying coin:', error); if (error instanceof Error) { if (error.message.includes('insufficient')) { throw new Error("Insufficient APT balance to pay for coin deployment transaction fees"); } if (error.message.includes('already exists')) { throw new Error("A coin with this configuration already exists for this account"); } if (error.message.includes('invalid')) { throw new Error("Invalid coin parameters. Check name, symbol, and decimals"); } } throw new Error(`Failed to deploy coin: ${error instanceof Error ? error.message : String(error)}`); } }
  • Type guard function for validating the structure and types of deploy_coin input arguments.
    export function isDeployCoinArgs(args: unknown): args is { name: string; symbol: string; decimals?: number; icon_url?: string; project_url?: string; max_gas_amount?: number; } { return ( typeof args === "object" && args !== null && "name" in args && typeof (args as any).name === "string" && "symbol" in args && typeof (args as any).symbol === "string" && (!(args as any).decimals || typeof (args as any).decimals === "number") && (!(args as any).icon_url || typeof (args as any).icon_url === "string") && (!(args as any).project_url || typeof (args as any).project_url === "string") && (!(args as any).max_gas_amount || typeof (args as any).max_gas_amount === "number") ); }
  • src/index.ts:50-52 (registration)
    Addition of DEPLOY_COIN tool to the TOOLS_LIST array for listTools response.
    DEPLOY_COIN, MINT_COIN, REGISTER_COIN,

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/punkpeye/aptos-mcp'

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