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'],
      },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it handles 'bytecode deployment, constructor encoding, gas estimation, receipt polling,' returns 'contract address, transaction hash, deployment details,' incurs 'gas fees for contract creation,' and has an 'AUTO-KEY' feature for optional private key usage. However, it lacks details on error handling, rate limits, or specific gas estimation methods, preventing a perfect score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections (HANDLES, RETURNS, COSTS, AUTO-KEY, USE FOR) and front-loaded key information. Each sentence earns its place by providing essential details without redundancy, such as clarifying the optional private key and specifying the target (Hedera EVM). It avoids unnecessary elaboration while covering critical aspects efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of smart contract deployment and no output schema, the description does a good job covering inputs, behaviors, and outputs. It explains what the tool handles, returns, costs, and key parameter usage. However, without annotations or an output schema, it could benefit from more detail on error cases or the structure of 'deployment details,' slightly reducing completeness for this advanced operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing a baseline of 3. The description adds some value by explaining that 'privateKey is OPTIONAL - automatically uses MCP operator account if not provided,' which clarifies usage beyond the schema's 'optional' note. However, it does not elaborate on the semantics of 'bytecode,' 'abi,' or 'constructorArgs' beyond what the schema already describes (e.g., format details for constructor arguments).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Deploy smart contract') and target resource ('to Hedera via JSON-RPC'), distinguishing it from sibling tools like 'deploy_contract' (which may use a different method) and 'rpc_call_contract' (which calls existing contracts). It includes the implementation details (bytecode deployment, constructor encoding, etc.) that further clarify its unique purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states 'USE FOR: Deploying Solidity contracts to Hedera EVM,' providing clear context for when to use this tool. It also distinguishes it from alternatives by specifying 'via JSON-RPC' (unlike 'deploy_contract' which might use other protocols) and mentions the optional 'privateKey' parameter with automatic fallback to the MCP operator account, guiding usage decisions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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