mox¶
🐍 Pythonic Smart Contract Development Framework
usage: mox [-h] [-d] [-q]
{init,compile,build,test,run,script,deploy,wallet,console,install,purge,config,explorer}
...
Positional Arguments¶
- command
Possible choices: init, compile, build, test, run, script, deploy, wallet, console, install, purge, config, explorer
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] [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
compile (build)¶
Compiles all Vyper contracts in the project.
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]
Named Arguments¶
- -d, --debug
Run in debug mode
Default:
False
- -q, --quiet
Suppress all output except errors
Default:
False
test¶
Runs pytest with boa context.
mox test [-h] [-d] [-q] [--fork] [--network NETWORK | --url URL] [-k [K]]
[--coverage COVERAGE] [-m [M]] [-x] [-s] [--capture [CAPTURE]]
[--lf] [--cache-clear] [--disable-warnings] [--full-trace] [--pdb]
[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
If you want to fork the RPC.
Default:
False
- --network
Alias of the network (from the moccasin.toml).
- --url, --rpc
RPC URL to run the script on.
- -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.
- --coverage
Run tests with coverage
- -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
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
run (script)¶
Runs a script with the project’s context.
mox run [-h] [-d] [-q] [--fork] [--network NETWORK | --url URL]
[--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
If you want to fork the RPC.
Default:
False
- --network
Alias of the network (from the moccasin.toml).
- --url, --rpc
RPC URL to run the script on.
- --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] [--network NETWORK | --url URL]
[--account ACCOUNT | --private-key PRIVATE_KEY]
[--password PASSWORD | --password-file-path PASSWORD_FILE_PATH]
contract_name
Positional Arguments¶
- contract_name
Name of 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
If you want to fork the RPC.
Default:
False
- --network
Alias of the network (from the moccasin.toml).
- --url, --rpc
RPC URL to run the script on.
- --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,inspect,decrypt,dk,delete,d}
...
Positional Arguments¶
- wallet_command
Possible choices: list, ls, generate, g, new, import, i, add, inspect, 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
inspect¶
View the JSON of a keystore file
mox wallet inspect [-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] [--network NETWORK | --url URL]
Named Arguments¶
- -d, --debug
Run in debug mode
Default:
False
- -q, --quiet
Suppress all output except errors
Default:
False
- --fork
If you want to fork the RPC.
Default:
False
- --network
Alias of the network (from the moccasin.toml).
- --url, --rpc
RPC URL to run the script on.
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]
[--uri URI | --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
- --uri
API URI endpoint for explorer.
- --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