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 [directory] [options]

1.2. Options

Option
Description
Default

directory

Directory to initialize project

./

--force, -f

Overwrite existing files if they already exist (asks confirmation)

false

1.3. Examples

# Initialize a fresh project using default settings
yarn mimic init

# Initialize in a specific directory
yarn mimic init ./my-task

# Force initialization, overwriting existing files (will ask for confirmation)
yarn mimic init ./my-task --force

1.4. Output

When --force is used in a non-empty directory, the CLI asks for confirmation before deleting contents.

After scaffolding, the CLI runs yarn install and then yarn codegen inside the initialized directory to set up dependencies and generate types.

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:


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

2.2. Options

Option
Description
Default

--manifest, -m <path>

Specify a custom manifest file path

manifest.yaml

--output, -o <dir>

Output directory for generated types

./src/types

--clean, -c

Remove existing generated types before generating new files (asks confirmation)

false

2.3. Examples

2.4. Output

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

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

circle-info

For details about how ABI wrappers are generated and how to use them (read/write functions, tuples, arrays, and events), see the ABI wrappers guide.


3. Compile

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

3.1. Usage

3.2. Options

Option
Description
Default

--task, -t <path>

Path to the AssemblyScript entry file

src/task.ts

--manifest, -m <path>

Path to the manifest file to validate

manifest.yaml

--output, -o <directory>

Output directory for compiled artifacts

build

3.3. Examples

3.4. Outputs

  • build/task.wasm - Compiled WebAssembly binary

  • build/manifest.json - Processed manifest configuration

The CLI validates the manifest before compiling. If the compilation fails, it reports an error and suggestions.


4. Login

Authenticates with Mimic by storing your API key locally. This allows you to deploy tasks without having to provide your API key every time. Credentials are stored securely in ~/.mimic/credentials.

circle-info

You can retrieve your API key from the Mimic explorerarrow-up-right under your account settings.

4.1. Usage

4.2. Options

Option
Description
Default

--profile, -p <name>

Profile name to use for this credential

default

--api-key, -k <key>

API key (non-interactive mode)

-

--force-login, -f

Force login even if profile exists

false

4.3. Examples

4.4. Behavior

In interactive mode, the CLI prompts you to:

  1. Enter your API key (masked input)

  2. Enter a profile name (defaults to "default")

If a profile already exists, you'll be asked to confirm before overwriting it (unless --force-login is used).

circle-info

Profile names cannot contain [, ], or = characters.


5. Logout

Removes stored credentials for a specific profile. This is useful when you want to revoke local access or clean up old credentials.

5.1. Usage

5.2. Options

Option
Description
Default

--profile, -p <name>

Profile name to remove

default

--force, -f

Skip confirmation prompt

false

5.3. Examples


6. Profiles

Lists all configured authentication profiles stored in ~/.mimic/credentials. This is useful for checking which profiles are available and which one is set as default.

6.1. Usage

6.2. Options

No options available for this command.

6.3. Examples

6.4. Output


7. 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.

circle-info

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

7.1. Usage

7.2. Options

Option
Description
Default

--api-key, -k <api-key>

Your account api key

-

--input, -i <directory>

Directory containing the compiled artifacts

build

--output, -o <directory>

Output directory for deployment CID

build

--url, -u <url>

Mimic Registry base URL

https://api-protocol.mimic.fi

--skip-compile

Skip codegen and compile steps before uploading

false

--profile, -p <name>

Profile name to use for the deployment.

-

circle-info

If neither an API key nor a profile is specified, the default profile will be used

7.3. Examples

7.4. Validation and Outputs

Before uploading, the CLI validates that the input directory exists and includes:

  • manifest.json

  • task.wasm

On success:

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


8. Test

Runs task tests using mocha. By default, it performs codegen and compile first, then executes tests/**/*.spec.ts.

8.1. Usage

8.2. Options

Option
Description
Default

--directory, -d <path>

Task directory to run tests from

./

--skip-compile

Skip codegen and compile steps before tests

false

8.3. Behavior

  • If not skipped, runs yarn mimic codegen and yarn mimic compile in the target directory.

  • Executes tests using mocha via tsx: yarn tsx ./node_modules/mocha/bin/mocha.js tests/**/*.spec.ts.

Last updated