Skip to main content
Glama

deploy-contract

Deploy smart contracts to the blockchain by providing bytecode and constructor arguments, enabling secure and efficient contract creation through MetaMask MCP.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
abiYesThe contract's ABI.
argsNoArguments to pass when deploying the contract. Inferred from abi.
bytecodeYesThe contract's bytecode.

Implementation Reference

  • The main handler function that deploys the contract using wagmi's deployContract, returns the transaction hash on success or an error message on failure.
    execute: async (args) => { try { const result = await deployContract(wagmiConfig, args); 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 for tool inputs: abi (ABI description), args (optional array of constructor arguments), bytecode (contract bytecode).
    parameters: z.object({ abi: Abi.describe("The contract's ABI."), args: z.unknown().array().optional().describe("Arguments to pass when deploying the contract. Inferred from abi."), bytecode: Calldata.describe("The contract's bytecode."), }),
  • Exports the registration function for the deploy-contract tool, which adds it to the FastMCP server.
    export function registerDeployContractTools(server: FastMCP, wagmiConfig: Config): void { server.addTool({ name: "deploy-contract", description: "Deploy a contract to the network, given bytecode, and constructor arguments.", parameters: z.object({ abi: Abi.describe("The contract's ABI."), args: z.unknown().array().optional().describe("Arguments to pass when deploying the contract. Inferred from abi."), bytecode: Calldata.describe("The contract's bytecode."), }), execute: async (args) => { try { const result = await deployContract(wagmiConfig, args); 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, }, ], }; } }, }); };
  • Invocation of the deploy-contract tool registration during overall tools registration.
    registerDeployContractTools(server, wagmiConfig);

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/metamask-mcp'

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