CLI Command Reference

mox

🐍 Pythonic Smart Contract Development Framework

usage: mox [-h] [-d] [-q]
           {init,compile,build,test,run,script,deploy,wallet,console,install,purge,config,explorer,inspect,deployments,utils,u,util} ...

Positional Arguments

command

Possible choices: init, compile, build, test, run, script, deploy, wallet, console, install, purge, config, explorer, inspect, deployments, utils, u, util

Named Arguments

-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

Sub-commands

init

This will create a basic directory structure at the path you specific, which looks like: . ├── README.md ├── moccasin.toml ├── script │ └── deploy.py ├── src │ └── Counter.vy └── tests

├── conftest.py └── test_counter.py

mox init [-h] [-d] [-q] [-f] [--vscode] [--pyproject] [path]
Positional Arguments
path

Path of the new project, defaults to current directory.

Default: .

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

-f, --force

Overwrite existing project.

Default: False

--vscode

Add a .vscode/settings.json file.

Default: False

--pyproject

Add a pyproject.toml file.

Default: False

compile (build)

Compiles a specific Vyper contract or all vyper contracts in the project.

If no contract or contract path is given, this command will: 1. Find all .vy files in the src/ directory 2. Compile each file using the Vyper compiler 3. Output the compiled artifacts to the out/ directory

Use this command to prepare your contracts for deployment or testing.

mox compile [-h] [-d] [-q] [--network NETWORK | --is_zksync [IS_ZKSYNC]]
            [contract_or_contract_path]
Positional Arguments
contract_or_contract_path

Optional argument to compile a specific contract.

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

--network

Alias of the network (from the moccasin.toml).

--is_zksync

test

Runs pytest with boa context.

mox test [-h] [-d] [-q] [--fork [FORK]] [--network NETWORK | --url URL |
         --prompt-live [PROMPT_LIVE]] [--db-path DB_PATH]
         [--save-to-db [SAVE_TO_DB]] [--account ACCOUNT |
         --private-key PRIVATE_KEY] [--password PASSWORD |
         --password-file-path PASSWORD_FILE_PATH] [--gas-profile] [-k [K]]
         [-m [M]] [-x] [-s] [--capture  [CAPTURE ]] [--lf] [--cache-clear]
         [--disable-warnings] [--full-trace] [--pdb] [--coverage] [--cov COV]
         [--cov-report [COV_REPORT ...]] [--cov-config COV_CONFIG]
         [--no-cov-on-fail] [--no-cov] [--cov-reset]
         [--cov-fail-under COV_FAIL_UNDER] [--cov-append] [--cov-branch]
         [--cov-context COV_CONTEXT] [--tb {auto,long,short,no,line,native}]
         [-v] [--hypothesis-seed HYPOTHESIS_SEED] [-n NUMPROCESSES]
         [--dist {load,loadscope,loadfile,loadgroup,no,worksteal}]
         [file_or_dir]
Positional Arguments
file_or_dir

Name of the test or folder to run tests on, or the path to your script.

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

--fork
--network

Alias of the network (from the moccasin.toml).

--url, --rpc

RPC URL to run the script on.

--prompt-live

Prompt the user to make sure they want to run this script.

--db-path

The location of your database, defaults to your working project’s database in your {CONFIG_NAME}.

--save-to-db

Save the deployment to the database.

--account

Keystore account you want to use.

--private-key

Private key you want to use to get an unlocked account.

--password

Password for the keystore account.

--password-file-path

Path to the file containing the password for the keystore account.

--gas-profile

Get an output on gas use for test functions.

Default: False

-k
Only run tests which match the given substring expression. An expression is a Python evaluable expression where all names are

substring-matched against test names and their parent classes. Example: -k ‘test_method or test_other’ matches all test functions and classes whose name contains ‘test_method’ or ‘test_other’, while -k ‘not test_method’ matches those that don’t contain ‘test_method’ in their names. -k ‘not test_method and not test_other’ will eliminate the matches. Additionally keywords are matched to classes and functions containing extra names in their ‘extra_keyword_matches’ set, as well as functions which have names assigned directly to them. The matching is case-insensitive.

-m

Only run tests matching given mark expression. For example: -m ‘mark1 and not mark2’.

-x, --exitfirst

Exit instantly on first error or failed test.

Default: False

-s

A way to show print lines from tests. Shortcut for –capture=no

Default: False

--capture

Per-test capturing method: one of fd|sys|no|tee-sys

--lf, --last-failed

Rerun only the tests that failed at the last run (or all if none failed).

Default: False

--cache-clear

Remove all cache contents at start of test run.

Default: False

--disable-warnings, --disable-pytest-warnings

Disable warnings summary.

Default: False

--full-trace

Don’t cut any tracebacks (default is to cut)

Default: False

--pdb

Start the debugger for each test that fails.

Default: False

--coverage

Shorthand for adding –cov=. –cov-branch.

Default: False

--cov

Coverage target directory.

--cov-report

Type of report to generate: term, term-missing, annotate, html, xml, json, lcov (multi-allowed). term, term- missing may be followed by “:skip-covered”. annotate, html, xml, json and lcov may be followed by “:DEST” where DEST specifies the output location. Use –cov-report= to not generate any output..

--cov-config

Coverage config file, defaults to a moccasin internal config file loading the boa plugin.

--no-cov-on-fail

Do not report coverage if test run fails.

Default: False

--no-cov

Disable coverage report.

Default: False

--cov-reset

Reset cov sources accumulated in options so far. Mostly useful for scripts and configuration files.

Default: False

--cov-fail-under

Fail if the total coverage is less than this value.

--cov-append

Do not delete coverage but append to current. Default: False.

Default: False

--cov-branch

Enable branch coverage.

Default: False

--cov-context

Coverage context to add to the coverage data.

--tb

Possible choices: auto, long, short, no, line, native

Traceback print mode

-v, --verbose

Verbosity level

--hypothesis-seed

Random seed to get the same run as a prior run.

-n, --numprocesses

Number of processes to use (auto/NUM)

--dist

Possible choices: load, loadscope, loadfile, loadgroup, no, worksteal

Load distribution mode

run (script)

Runs a script with the project’s context.

mox run [-h] [-d] [-q] [--fork [FORK]] [--network NETWORK | --url URL |
        --prompt-live [PROMPT_LIVE]] [--db-path DB_PATH]
        [--save-to-db [SAVE_TO_DB]] [--account ACCOUNT |
        --private-key PRIVATE_KEY] [--password PASSWORD |
        --password-file-path PASSWORD_FILE_PATH]
        script_name_or_path
Positional Arguments
script_name_or_path

Name of the script in the script folder, or the path to your script.

Default: './script/deploy.py'

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

--fork
--network

Alias of the network (from the moccasin.toml).

--url, --rpc

RPC URL to run the script on.

--prompt-live

Prompt the user to make sure they want to run this script.

--db-path

The location of your database, defaults to your working project’s database in your {CONFIG_NAME}.

--save-to-db

Save the deployment to the database.

--account

Keystore account you want to use.

--private-key

Private key you want to use to get an unlocked account.

--password

Password for the keystore account.

--password-file-path

Path to the file containing the password for the keystore account.

deploy

Deploys a contract named in the config with a deploy script.

mox deploy [-h] [-d] [-q] [--fork [FORK]] [--network NETWORK | --url URL |
           --prompt-live [PROMPT_LIVE]] [--db-path DB_PATH]
           [--save-to-db [SAVE_TO_DB]] [--account ACCOUNT |
           --private-key PRIVATE_KEY] [--password PASSWORD |
           --password-file-path PASSWORD_FILE_PATH]
           contract_name
Positional Arguments
contract_name

Name of your named contract in your moccasin.toml to deploy.

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

--fork
--network

Alias of the network (from the moccasin.toml).

--url, --rpc

RPC URL to run the script on.

--prompt-live

Prompt the user to make sure they want to run this script.

--db-path

The location of your database, defaults to your working project’s database in your {CONFIG_NAME}.

--save-to-db

Save the deployment to the database.

--account

Keystore account you want to use.

--private-key

Private key you want to use to get an unlocked account.

--password

Password for the keystore account.

--password-file-path

Path to the file containing the password for the keystore account.

wallet

Wallet management utilities.

mox wallet [-h] [-d] [-q]
           {list,ls,generate,g,new,import,i,add,view,decrypt,dk,delete,d} ...
Positional Arguments
wallet_command

Possible choices: list, ls, generate, g, new, import, i, add, view, decrypt, dk, delete, d

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

Sub-commands
list (ls)

List all the accounts in the keystore default directory

mox wallet list [-h]
generate (g, new)

Create a new account with a random private key

mox wallet generate [-h] [--save] [--password PASSWORD |
                    --password-file PASSWORD_FILE]
                    name
Positional Arguments
name

Name of account

Named Arguments
--save

Save to keystore

Default: False

--password

Password for the keystore

--password-file

File containing the password for the keystore

import (i, add)

Import a private key into an encrypted keystore

mox wallet import [-h] name
Positional Arguments
name

Name of account to import

view

View the JSON of a keystore file

mox wallet view [-h] keystore_file_name
Positional Arguments
keystore_file_name

Name of keystore file

decrypt (dk)

Decrypt a keystore file to get the private key

mox wallet decrypt [-h] [--password PASSWORD |
                   --password-file-path PASSWORD_FILE_PATH] [--print-key]
                   keystore_file_name
Positional Arguments
keystore_file_name

Name of the keystore file to decrypt

Named Arguments
--password

Password for the keystore account.

--password-file-path

Path to the file containing the password for the keystore account.

--print-key, -p

Print the private key to the console

Default: False

delete (d)

Delete a keystore file

mox wallet delete [-h] keystore_file_name
Positional Arguments
keystore_file_name

Name of keystore file

console

BETA, USE AT YOUR OWN RISK: Interact with the network in a python shell.

mox console [-h] [-d] [-q] [--fork [FORK]] [--network NETWORK | --url URL |
            --prompt-live [PROMPT_LIVE]] [--db-path DB_PATH]
            [--save-to-db [SAVE_TO_DB]] [--account ACCOUNT |
            --private-key PRIVATE_KEY] [--password PASSWORD |
            --password-file-path PASSWORD_FILE_PATH]
Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

--fork
--network

Alias of the network (from the moccasin.toml).

--url, --rpc

RPC URL to run the script on.

--prompt-live

Prompt the user to make sure they want to run this script.

--db-path

The location of your database, defaults to your working project’s database in your {CONFIG_NAME}.

--save-to-db

Save the deployment to the database.

--account

Keystore account you want to use.

--private-key

Private key you want to use to get an unlocked account.

--password

Password for the keystore account.

--password-file-path

Path to the file containing the password for the keystore account.

install

Installs the project’s dependencies. The first argument is the requirements, given as a pip-compatible strings and/or moccasin github formatted dependencies. - Pip-compatible strings download dependencies as regular python packages from PyPI. - Moccasin github formatted dependencies download dependencies from the Moccasin github repository.

Moccasin github formatted dependencies are formatted as:

GITHUB_ORG/GITHUB_REPO@[@VERSION]

Where: - GITHUB_ORG is the github organization or user that owns the repository. - GITHUB_REPO is the name of the repository. - VERSION is the optional version of the repository to download. If not provided, the latest version is downloaded.

Examples: - pcaversaccio/snekmate@0.1.0 # Moccasin GitHub formatted dependency - snekmate==0.1.0 # Pip-compatible string

mox install [-h] [-d] [-q] [requirements ...]
Positional Arguments
requirements

Requirements, given as a pip-compatible strings and/or moccasin github formatted dependencies.

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

purge

Purge the given dependency.

mox purge [-h] [-d] [-q] packages [packages ...]
Positional Arguments
packages

Package name, given as a pip-compatible string and/or moccasin github formatted dependency.

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

config

View the Moccasin configuration.

mox config [-h] [-d] [-q]
Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

explorer

Work with block explorers to get data.

mox explorer [-h] [-d] [-q] {fetch,get,list} ...
Positional Arguments
explorer_command

Possible choices: fetch, get, list

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

Sub-commands
fetch (get)

Retreive the ABI of a contract from a block explorer.

This command will attempt to use the environment variable ETHERSCAN_API_KEY as the API key for Etherscan. If this environment variable is not set, you can provide the API key as an argument to the command.

mox explorer fetch [-h] [-d] [-q] [--name NAME] [--api-key API_KEY]
                   [--ignore-config] [--save-abi-path SAVE_ABI_PATH] [--save]
                   [--explorer-uri EXPLORER_URI |
                   --explorer-type EXPLORER_TYPE | --network NETWORK]
                   address
Positional Arguments
address

The address you want to pull from.

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

--name

Optional name for the contract.

--api-key, --explorer-api-key

API key for the block explorer.

--ignore-config, -i

Don’t pull values from the config.

Default: False

--save-abi-path

Location to save the returned abi. This will only be applied if you also add the ‘–save’ flag.

--save

If added, the ABI will be saved to the ‘save-abi-path’ given in the command line or config.

Default: False

--explorer-uri

API URI endpoint for explorer.

--explorer-type

blockscout, etherscan, or zksyncexplorer.

--network

Name/alias of the network (from the moccasin.toml). If chain_id is set in the config, you may also use that.

list

List all natively supported block explorers and chains.

mox explorer list [-h] [--by-id] [--json]
Named Arguments
--by-id

List by chain id.

Default: False

--json

Format as json.

Default: False

inspect

Inspect compiler data of a contract.

This command will directly use the Vyper compiler to access this data. For example, to get function signatures and selectors run:

mox inspect src/Counter.vy methods

or

mox inspect Counter methods

mox inspect [-h]
            contract
            {methods,abi,natspec,storage-layout,ir-nodes,ir-runtime,function-signatures,function-selectors,selectors,signatures,assembly,venom-functions,bytecode,bytecode-runtime}
Positional Arguments
contract

Path or Contract name of the contract you want to inspect.

inspect_type

Possible choices: methods, abi, natspec, storage-layout, ir-nodes, ir-runtime, function-signatures, function-selectors, selectors, signatures, assembly, venom-functions, bytecode, bytecode-runtime

Type of inspection you want to do.

deployments

View deployments of the project from your DB.

The –format-level will determine how much information you want to print based on your deployment.

Format levels: - 0: Contract Address - 1: Contract Address and Name - 2: Contract Address, Name, and Source Code - 3: Everything - 4: Raw JSON

mox deployments [-h] [-d] [-q] [--format-level FORMAT_LEVEL] [--checked]
                [--limit LIMIT] [--fork [FORK]] [--network NETWORK |
                --url URL | --prompt-live [PROMPT_LIVE]] [--db-path DB_PATH]
                [--save-to-db [SAVE_TO_DB]]
                contract_name
Positional Arguments
contract_name

Name of the contract to get, or “all”.

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

--format-level, -f

Format level of how much information you want to print based on your deployment.

Default: 1

--checked

Only return contracts that match the current edition of the code by comparing integrity hashes.

Default: False

--limit

Limit the number of deployments to get.

--fork
--network

Alias of the network (from the moccasin.toml).

--url, --rpc

RPC URL to run the script on.

--prompt-live

Prompt the user to make sure they want to run this script.

--db-path

The location of your database, defaults to your working project’s database in your {CONFIG_NAME}.

--save-to-db

Save the deployment to the database.

utils (u, util)

Helpful utilities.

mox utils [-h] [-d] [-q]
          {zero,zero-address,zero_address,address-zero,address_zero} ...
Positional Arguments
utils_command

Possible choices: zero, zero-address, zero_address, address-zero, address_zero

Named Arguments
-d, --debug

Run in debug mode

Default: False

-q, --quiet

Suppress all output except errors

Default: False

Sub-commands
zero (zero-address, zero_address, address-zero, address_zero)

Get the zero address.

mox utils zero [-h]