deploy-contract
Deploy smart contracts to blockchain networks using bytecode, ABI, and constructor arguments for secure AI-powered blockchain interactions.
Instructions
Deploy a contract to the network, given bytecode, and constructor arguments
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| abi | Yes | ||
| args | Yes | ||
| bytecode | Yes |
Implementation Reference
- Handler function that parses inputs, calls wagmi's deployContract, returns transaction hash or error message.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: abi (string), args (array of strings), bytecode (string).parameters: z.object({ abi: z.string(), args: z.string().array(), bytecode: z.string(), }),
- packages/metamask-mcp/src/tools/deploy-contract.ts:8-59 (registration)Function that registers the 'deploy-contract' tool on the FastMCP server with full definition.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, } ] } } }, }); };
- packages/metamask-mcp/src/index.ts:41-41 (registration)Invocation of the registration function during server setup to add the tool.registerDeployContractTools(server);