Skip to main content
Glama

deploy_contract

Deploy smart contracts to Hedera networks with auto-detection of project frameworks, constructor argument support, and automatic verification on HashScan.

Instructions

Deploy smart contract to Hedera with unified interface.

AUTO-DETECTS: Hardhat or Foundry project framework SUPPORTS: Constructor arguments, gas limits, auto-verification TRACKS: Deployment history with metadata

USE FOR: Production contract deployment, automated workflows, verified deployments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contractNameYesContract name
networkYesTarget network
constructorArgsNoConstructor arguments
verifyNoAuto-verify on HashScan
frameworkNoFramework (auto-detected if not specified)

Implementation Reference

  • Primary handler function that executes the deploy_contract tool logic. Parses arguments, calls deploymentService.deployContract, formats ToolResult with success status, deployment details, and metadata.
    export async function deployContract(args: {
      contractName: string;
      network: HederaNetwork;
      constructorArgs?: any[];
      framework?: 'hardhat' | 'foundry' | 'direct';
      fromAlias?: string;
      privateKey?: string;
      gasLimit?: number;
      verify?: boolean;
      metadata?: Record<string, any>;
    }): Promise<ToolResult> {
      try {
        logger.info('Starting contract deployment', {
          contractName: args.contractName,
          network: args.network,
          framework: args.framework || 'auto-detect',
          verify: args.verify || false,
        });
    
        const result = await deploymentService.deployContract({
          contractName: args.contractName,
          network: args.network,
          constructorArgs: args.constructorArgs,
          framework: args.framework,
          fromAlias: args.fromAlias,
          privateKey: args.privateKey,
          gasLimit: args.gasLimit,
          verify: args.verify,
        });
    
        if (result.success && result.record) {
          return {
            success: true,
            data: {
              deploymentId: result.record.id,
              contractName: result.record.contractName,
              contractAddress: result.record.contractAddress,
              network: result.record.network,
              framework: result.record.framework,
              transactionHash: result.record.transactionHash,
              gasUsed: result.record.gasUsed,
              constructorArgs: result.record.constructorArgs,
              status: result.record.status,
              verificationStatus: result.record.verificationStatus,
              hashScanUrl: result.record.hashScanUrl,
              deployedAt: result.record.deployedAt,
            },
            metadata: {
              executedVia: result.record.framework,
              command: 'deploy_contract',
            },
          };
        } else {
          return {
            success: false,
            error: result.error || 'Deployment failed',
            metadata: {
              executedVia: 'deployment-service',
              command: 'deploy_contract',
            },
          };
        }
      } catch (error: any) {
        logger.error('Contract deployment failed', { error: error.message });
        return {
          success: false,
          error: error.message,
          metadata: {
            executedVia: 'deployment-service',
            command: 'deploy_contract',
          },
        };
      }
    }
  • Tool definition including name, description, and inputSchema used for registration and validation of deploy_contract tool.
      {
        name: 'deploy_contract',
        description: `Deploy smart contract to Hedera with unified interface.
    
    AUTO-DETECTS: Hardhat or Foundry project framework
    SUPPORTS: Constructor arguments, gas limits, auto-verification
    TRACKS: Deployment history with metadata
    
    USE FOR: Production contract deployment, automated workflows, verified deployments.`,
        inputSchema: {
          type: 'object' as const,
          properties: {
            contractName: { type: 'string', description: 'Contract name' },
            network: {
              type: 'string',
              enum: ['mainnet', 'testnet', 'previewnet'],
              description: 'Target network',
            },
            constructorArgs: { type: 'array', items: {}, description: 'Constructor arguments' },
            verify: { type: 'boolean', description: 'Auto-verify on HashScan' },
            framework: {
              type: 'string',
              enum: ['hardhat', 'foundry', 'direct'],
              description: 'Framework (auto-detected if not specified)',
            },
          },
          required: ['contractName', 'network'],
        },
      },
  • src/index.ts:633-634 (registration)
    Registration and dispatch logic in the main MCP server request handler that routes 'deploy_contract' calls to the deployContract function.
    case 'deploy_contract':
      result = await deployContract(args as any);
  • Core deployment service method called by the tool handler. Handles framework detection, performs actual deployment based on Hardhat/Foundry/direct, tracks history, and verification.
    async deployContract(options: DeploymentOptions): Promise<DeploymentResult> {
      try {
        logger.info('Starting contract deployment', {
          contractName: options.contractName,
          network: options.network,
          framework: options.framework || 'auto-detect',
        });
    
        // Detect framework if not specified
        const framework = options.framework || (await this.detectFramework());
        if (!framework) {
          return {
            success: false,
            error: 'Could not detect deployment framework',
          };
        }
    
        // Generate deployment ID
        const deploymentId = this.generateDeploymentId(options.contractName, options.network);
    
        // Create pending deployment record
        const record: DeploymentRecord = {
          id: deploymentId,
          contractName: options.contractName,
          contractAddress: '', // Will be filled after deployment
          network: options.network,
          framework,
          deployer: options.fromAlias || 'unknown',
          deployedAt: new Date().toISOString(),
          transactionHash: '',
          gasUsed: 0,
          constructorArgs: options.constructorArgs || [],
          status: 'deploying',
          verificationStatus: 'not_verified',
        };
    
        // Deploy based on framework
        let deploymentData: any;
        switch (framework) {
          case 'hardhat':
            deploymentData = await this.deployWithHardhat(options);
            break;
          case 'foundry':
            deploymentData = await this.deployWithFoundry(options);
            break;
          case 'direct':
            deploymentData = await this.deployWithRPC(options);
            break;
        }
    
        if (!deploymentData.success) {
          record.status = 'failed';
          this.deploymentHistory.push(record);
          await this.saveDeploymentHistory();
    
          return {
            success: false,
            error: deploymentData.error,
            record,
          };
        }
    
        // Update record with deployment data
        record.contractAddress = deploymentData.address;
        record.transactionHash = deploymentData.transactionHash;
        record.gasUsed = deploymentData.gasUsed || 0;
        record.status = 'deployed';
        record.hashScanUrl = hashScanService.getContractUrl(deploymentData.address, options.network);
        record.compilerVersion = deploymentData.compilerVersion;
    
        // Auto-verify if requested
        if (options.verify) {
          logger.info('Auto-verifying contract on HashScan', {
            address: record.contractAddress,
            network: options.network,
          });
    
          record.verificationStatus = 'pending';
          const verifyResult = await this.verifyDeployment(record, framework);
          if (verifyResult) {
            record.verificationStatus = 'verified';
            record.status = 'verified';
          } else {
            record.verificationStatus = 'failed';
          }
        }
    
        // Save to history
        this.deploymentHistory.push(record);
        await this.saveDeploymentHistory();
    
        logger.info('Contract deployment successful', {
          contractName: record.contractName,
          address: record.contractAddress,
          network: record.network,
          transactionHash: record.transactionHash,
          verified: record.verificationStatus === 'verified',
        });
    
        return {
          success: true,
          record,
        };
      } catch (error: any) {
        logger.error('Contract deployment failed', { error: error.message });
        return {
          success: false,
          error: error.message,
        };
      }
Behavior3/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 adds useful context beyond basic functionality: it mentions auto-detection of Hardhat or Foundry, support for constructor arguments and gas limits, auto-verification, and tracking deployment history with metadata. However, it lacks details on permissions, rate limits, error handling, or response format, which are important for a deployment tool.

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 and front-loaded with the core purpose, followed by bullet-like sections (AUTO-DETECTS, SUPPORTS, TRACKS, USE FOR) that efficiently convey key information without waste. Every sentence earns its place by adding distinct value.

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 a deployment tool with no annotations and no output schema, the description does a good job covering purpose, usage, and behavioral traits. However, it lacks details on return values or error cases, which would be helpful for completeness. It compensates somewhat with clear usage guidelines and transparency.

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%, so the schema already documents all 5 parameters thoroughly. The description adds minimal value beyond the schema: it implies framework auto-detection and verification features but doesn't provide additional syntax or format details. This meets the baseline of 3 when schema coverage is high.

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 tool deploys smart contracts to Hedera with a unified interface, specifying the verb 'deploy' and resource 'smart contract'. It distinguishes from siblings like rpc_deploy_contract by emphasizing auto-detection of frameworks, constructor arguments, gas limits, and verification features, making it specific and differentiated.

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: Production contract deployment, automated workflows, verified deployments,' providing clear context on when to use this tool. It distinguishes from alternatives like verify_contract by focusing on deployment with verification, and from rpc_deploy_contract by highlighting framework auto-detection and tracking features.

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