deploy-mon-contract
Deploy smart contracts on the Monad testnet by providing contract bytecode, ABI, and constructor arguments, enabling integration and testing on the blockchain.
Instructions
Deploy a smart contract on Monad testnet
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"bytecode": "<bytecode>",
"abi": "<abi>"
},
"name": "deploy-mon-contract"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| abi | Yes | Contract ABI | |
| bytecode | Yes | Contract bytecode | |
| constructorArgs | No | Constructor arguments |
Implementation Reference
- src/tools/contract/deploy.ts:21-52 (handler)The handler function that executes the deployment of a smart contract on Monad testnet using viem wallet client.
async ({ bytecode, abi, constructorArgs }) => { try { // Create wallet client const client = await createWallet(); // Deploy contract const hash = await client.deployContract({ abi: JSON.parse(abi), bytecode: bytecode as `0x${string}`, args: constructorArgs || [], }); return { content: [ { type: "text", text: `Contract deployment transaction sent! Hash: ${hash}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to deploy contract. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); - src/tools/contract/deploy.ts:16-20 (schema)Zod input schema defining parameters for contract deployment: bytecode, ABI, and optional constructor arguments.
{ bytecode: z.string().describe("Contract bytecode"), abi: z.string().describe("Contract ABI"), constructorArgs: z.array(z.any()).optional().describe("Constructor arguments"), }, - src/tools/contract/deploy.ts:13-52 (registration)Core registration of the 'deploy-mon-contract' tool using server.tool(), specifying name, description, input schema, and handler function.
server.tool( "deploy-mon-contract", "Deploy a smart contract on Monad testnet", { bytecode: z.string().describe("Contract bytecode"), abi: z.string().describe("Contract ABI"), constructorArgs: z.array(z.any()).optional().describe("Constructor arguments"), }, async ({ bytecode, abi, constructorArgs }) => { try { // Create wallet client const client = await createWallet(); // Deploy contract const hash = await client.deployContract({ abi: JSON.parse(abi), bytecode: bytecode as `0x${string}`, args: constructorArgs || [], }); return { content: [ { type: "text", text: `Contract deployment transaction sent! Hash: ${hash}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to deploy contract. Error: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); - src/tools/contract/index.ts:6-7 (helper)Invocation of deployContractProvider within the contractProvider helper to register contract tools.
deployContractProvider(server); contractEventProvider(server); - src/index.ts:25-25 (helper)Invocation of contractProvider in main server initialization to register all contract tools including deploy-mon-contract.
contractProvider(server);