The Mimic CLI (@mimicprotocol/cli) is the main tool for scaffolding, building, and deploying functions. You use it via npx without a global install, or as a local dev dependency invoked through yarn mimic.
Installation
No global install required. Run any command directly with npx:
npx@mimicprotocol/cli<command>
Or add it as a local dev dependency and invoke it through yarn scripts:
yarnadd-D@mimicprotocol/cliyarnmimic<command>
Commands
init — Scaffold a new project
Creates a minimal project structure with a manifest file, a starter function, and all dependencies.
npx@mimicprotocol/cliinit [directory] [--force]
Option
Description
Default
directory
Where to initialize the project
./
--force, -f
Overwrite existing files (asks for confirmation)
false
Examples
Output structure
After scaffolding, the CLI automatically runs yarn install and yarn codegen.
codegen — Generate types from the manifest
Reads manifest.yaml and generates typed AssemblyScript interfaces for declared inputs and ABIs into src/types/.
Option
Description
Default
--manifest, -m
Path to manifest file
manifest.yaml
--output, -o
Output directory for generated types
./src/types
--clean, -c
Delete existing types before regenerating (asks confirmation)
false
Examples
Output
src/types/index.ts — Input parameter types
src/types/<ContractName>.ts — One file per ABI, with read/write methods and event decoders
Run codegen every time you change manifest.yaml. Generated files are meant to be committed — do not edit them manually.
compile — Build to WebAssembly
Validates the manifest and compiles your AssemblyScript function into a WASM binary.
Option
Description
Default
--function, -f
Path to entry file
src/function.ts
--manifest, -m
Path to manifest file
manifest.yaml
--output, -o
Output directory
build
Examples
Output
login — Save your API key locally
Stores credentials in ~/.mimic/credentials so you don't need to pass --api-key on every deploy.
Option
Description
Default
--profile, -p
Profile name
default
--api-key, -k
API key (skips interactive prompt)
—
--force-login, -f
Overwrite existing profile without confirmation
false
Examples
Retrieve your API key from the Mimic explorer under account settings. Profile names cannot contain [, ], or =.
logout — Remove stored credentials
profiles — List configured profiles
deploy — Upload to the Mimic Registry
Runs codegen + compile (unless skipped), uploads artifacts to IPFS, and registers the function in the Mimic Registry so relayers can discover it.
Option
Description
Default
--api-key, -k
API key
—
--profile, -p
Credential profile to use
default
--input, -i
Directory with compiled artifacts
build
--output, -o
Directory to write the CID file
build
--skip-compile
Skip codegen and compile
false
--url, -u
Registry base URL
https://api-protocol.mimic.fi
Examples
Before uploading, the CLI validates that build/ contains both manifest.json and function.wasm.
Output: build/CID.json — the IPFS Content Identifier for your deployed function.
test — Run function tests
Runs codegen + compile, then executes tests/**/*.spec.ts with Mocha.
Option
Description
Default
--directory, -d
Function directory to test
./
--skip-compile
Skip codegen and compile before tests
false
Multi-function projects (mimic.yaml)
For projects with more than one function, create a mimic.yaml at the project root. All commands (codegen, compile, test, deploy) will iterate over every function defined in it.
Filtering
mimic.yaml is optional — single-function projects can continue using individual command flags without it.
# New project in ./my-function
npx @mimicprotocol/cli init ./my-function
# Reinitialize in an existing directory
npx @mimicprotocol/cli init ./my-function --force
my-function/
├── manifest.yaml # Function metadata, inputs, and ABI references
├── package.json
├── tsconfig.json
└── src/
└── function.ts # Your AssemblyScript function
Configured profiles (stored in ~/.mimic/credentials):
* default (default)
* staging
* production
Use mimic deploy --profile <name> to deploy with a specific profile.
# Only run for specific functions
yarn mimic compile --include function-one function-two
# Run for all except one
yarn mimic codegen --exclude function-two
# Override the config file location
yarn mimic compile --config-file ./config/functions.yaml
# Ignore mimic.yaml entirely
yarn mimic compile --no-config --function ./src/function.ts