CLI

The Mimic Protocol CLI is a command-line tool for building, managing, and deploying automated blockchain tasks. Mimic Protocol is a blockchain automation protocol that allows developers to create programmable tasks that execute automatically based on predefined conditions.

1. Initialize

Initializes a new Mimic-compatible project structure in the current directory. This command will create a minimal folder layout, a manifest file, and example AssemblyScript task.

1.1. Usage

$ mimic init [options]

1.2. Options

Option
Description
Default

--force

Overwrite existing files if they already exist

false

1.3. Examples

# Initialize a fresh project using default settings
$ mimic init

# Force initialization, overwriting existing files
$ mimic init --force

1.4. Output

my-mimic-task/
├── manifest.yaml      # Task configuration
├── package.json       # Node.js dependencies
├── tsconfig.json      # TypeScript configuration
└── src/
    └── task.ts        # Main task implementation

The manifest describes metadata, inputs, and ABIs for your AssemblyScript task, so the CLI can validate, generate code, compile, and ultimately deploy your task. For example:

version: 1.0.0
name: Balance Monitoring Task
description: Monitors an account's token balance and creates a swap intent if conditions are met.
inputs:
  - chainId: uint32
  - account: address
  - tokenIn: address
  - tokenOut: address
  - slippage: uint32
  - threshold: uint32
abis:
  - ERC20: './abis/IERC20.json'

2. Codegen

Scans your manifest.yaml and generates typed interfaces for declared inputs and ABIs. This step is typically used to create or update TypeScript/AssemblyScript types for your project so you can safely reference them in your code.

2.1. Usage

$ mimic codegen [options]

2.2. Options

Option
Description
Default

--manifest <path>

Specify a custom manifest file path

manifest.yaml

--output <dir>

Output directory for generated types

types

--clean

Remove existing generated types before generating new files

false

2.3. Examples

# Generate types in the default "types" directory
$ mimic codegen

# Generate types from a custom manifest, output to a "generated" folder
$ mimic codegen --manifest ./custom-manifest.yaml --output generated

2.4. Output

  • ./src/types/index.ts - Input parameter types

  • ./src/types/[ContractName].ts - Contract interface types (one per ABI)


3. Compile

Compiles your AssemblyScript task into a Wasm binary, along with validating your manifest and producing any required runtime artifacts (like inputs.json). This step ensures you have a complete, ready-to-deploy package of your task logic and metadata.

3.1. Usage

$ mimic compile [options]

3.2. Options

Option
Description
Default

--task <path>

Path to the AssemblyScript entry file

src/task.ts

--manifest <path>

Path to the manifest file to validate

manifest.yaml

--output <directory>

Output directory for compiled artifacts

build

3.3. Examples

# Compile using the default task and manifest
$ mimic compile

# Compile a specific file, output to a custom directory
$ mimic compile --task ./tasks/myTask.ts --output ./out

3.4. Outputs

  • build/task.wasm - Compiled WebAssembly binary

  • build/task.wat - WebAssembly text format (human-readable)

  • build/manifest.json - Processed manifest configuration


4. Deploy

Uploads your compiled task artifacts to IPFS and registers it into the Mimic Registry so others can discover it. This step pins the result under a CID so relayers can discover and execute it.

You must retrieve your deployment key from the Mimic explorer under your account settings. If you don’t have one, create or copy it from there before running deploy.

4.1. Usage

$ mimic deploy [options]

4.2. Options

Option
Description
Default

--key <deploymentKey>

Your account deployment key

(no default)

--input <directory>

Directory containing the compiled artifacts

build

--output <directory>

Output directory for deployment CID

build

4.3. Examples

# Deploy from the default build directory, using your pre-configured key
$ mimic deploy --key my-key

# Deploy from a custom folder
$ mimic deploy --input ./dist --key my-key

# Specify a different output path
$ mimic deploy --input ./dist --key my-key --output ./dist

4.4. Outputs

  • build/CID.json - Contains the IPFS Content Identifier for your deployed task

Last updated