Skip to main content
Glama

deploy-contract

Deploy smart contracts to the blockchain by providing bytecode and constructor arguments. Simplifies interactions for AI-powered blockchain applications through secure, private key-free integration with MetaMask.

Instructions

Deploy a contract to the network, given bytecode, and constructor arguments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
abiYes
argsYes
bytecodeYes

Implementation Reference

  • The main handler function that deploys the contract using wagmi/core's deployContract. Parses ABI, args, bytecode, executes deployment, returns transaction hash or handles errors appropriately.
    execute: async (_args) => { try { const abi = JSON.parse(_args.abi) as Abi const args = _args.args const bytecode = _args.bytecode as Hex const result = await deployContract(wagmiConfig, { abi, args, bytecode, }) 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 schema defining the input parameters for the deploy-contract tool: abi (string), args (array of strings), bytecode (string).
    parameters: z.object({ abi: z.string(), args: z.string().array(), bytecode: z.string(), }),
  • Function that registers the deploy-contract tool with the FastMCP server, defining name, description, schema, and handler.
    export function registerDeployContractTools(server: FastMCP): void { server.addTool({ name: "deploy-contract", description: "Deploy a contract to the network, given bytecode, and constructor arguments", parameters: z.object({ abi: z.string(), args: z.string().array(), bytecode: z.string(), }), execute: async (_args) => { try { const abi = JSON.parse(_args.abi) as Abi const args = _args.args const bytecode = _args.bytecode as Hex const result = await deployContract(wagmiConfig, { abi, args, bytecode, }) 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, } ] } } }, }); };
  • Top-level call to register the deploy-contract tool in the main MetaMask MCP server initialization.
    registerDeployContractTools(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