Skip to main content
Glama

rpc_deploy_contract

Deploy smart contracts to Hedera EVM using JSON-RPC. Handles bytecode deployment, constructor encoding, gas estimation, and returns contract address with transaction details.

Instructions

Deploy smart contract to Hedera via JSON-RPC.

HANDLES: Bytecode deployment, constructor encoding, gas estimation, receipt polling RETURNS: Contract address, transaction hash, deployment details COSTS: Gas fees for contract creation AUTO-KEY: privateKey is OPTIONAL - automatically uses MCP operator account if not provided

USE FOR: Deploying Solidity contracts to Hedera EVM.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bytecodeYesContract bytecode (0x...)
abiNoContract ABI
constructorArgsNoConstructor arguments
privateKeyNoDeployer private key (optional - uses MCP operator)

Implementation Reference

  • Core handler function that executes the rpc_deploy_contract tool. Validates input, calls jsonRpcService.deployContract, formats success/error responses as ToolResult.
    export async function rpcDeployContract(args: { bytecode: string; abi?: any[]; constructorArgs?: any[]; gasLimit?: number; privateKey?: string; fromAlias?: string; network?: 'mainnet' | 'testnet' | 'previewnet' | 'local'; }): Promise<ToolResult> { try { logger.info('Deploying contract via RPC', { hasConstructorArgs: !!args.constructorArgs?.length, network: args.network, }); // Validate bytecode if (!args.bytecode.startsWith('0x')) { throw new Error('Bytecode must start with 0x'); } const result = await jsonRpcService.deployContract({ bytecode: args.bytecode, abi: args.abi, constructorArgs: args.constructorArgs, gasLimit: args.gasLimit, privateKey: args.privateKey, fromAlias: args.fromAlias, network: args.network, }); return { success: true, data: { contractAddress: result.contractAddress, transactionHash: result.transactionHash, blockNumber: result.receipt.blockNumber, gasUsed: result.receipt.gasUsed, status: result.receipt.status === '0x1' ? 'success' : 'failed', }, metadata: { executedVia: 'json_rpc_relay', command: 'contract deploy', }, }; } catch (error) { logger.error('Contract deployment failed', { error }); return { success: false, error: error instanceof Error ? error.message : 'Unknown error occurred', metadata: { executedVia: 'json_rpc_relay', command: 'contract deploy', }, }; }
  • Input schema definition for rpc_deploy_contract tool used in MCP tool listing.
    { name: 'rpc_deploy_contract', description: `Deploy smart contract to Hedera via JSON-RPC. HANDLES: Bytecode deployment, constructor encoding, gas estimation, receipt polling RETURNS: Contract address, transaction hash, deployment details COSTS: Gas fees for contract creation AUTO-KEY: privateKey is OPTIONAL - automatically uses MCP operator account if not provided USE FOR: Deploying Solidity contracts to Hedera EVM.`, inputSchema: { type: 'object' as const, properties: { bytecode: { type: 'string', description: 'Contract bytecode (0x...)' }, abi: { type: 'array', items: {}, description: 'Contract ABI' }, constructorArgs: { type: 'array', items: {}, description: 'Constructor arguments' }, privateKey: { type: 'string', description: 'Deployer private key (optional - uses MCP operator)' }, }, required: ['bytecode'], },
  • src/index.ts:611-612 (registration)
    Registration in the main tool dispatcher switch statement that routes calls to the rpcDeployContract handler.
    case 'rpc_deploy_contract': result = await rpcDeployContract(args as any);
  • Detailed input schema for rpc_deploy_contract in the exported rpcTools array (source definition).
    { name: 'rpc_deploy_contract', description: 'Deploy smart contract to Hedera via JSON-RPC. Handles bytecode deployment, constructor arguments encoding, gas estimation, transaction signing, submission, and receipt polling. Returns contract address and transaction details.', inputSchema: { type: 'object' as const, properties: { bytecode: { type: 'string', description: 'Contract bytecode in hex format (must start with 0x)', }, abi: { type: 'array', description: 'Optional: Contract ABI for constructor encoding', items: {}, }, constructorArgs: { type: 'array', description: 'Optional: Constructor arguments', items: {}, }, gasLimit: { type: 'number', description: 'Optional: Gas limit override (auto-estimated if not provided)', }, privateKey: { type: 'string', description: 'Optional: Private key in DER format (or use fromAlias)', }, fromAlias: { type: 'string', description: 'Optional: Address book alias to use for deployment', }, network: { type: 'string', enum: ['mainnet', 'testnet', 'previewnet', 'local'], description: 'Target network (default: current network)', }, }, required: ['bytecode'], },

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/justmert/hashpilot'

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