Skip to main content

Sui Move CLI

The Sui CLI move command provides several commands for working with Move source code. A typical usage of sui move is to compile and test the Move code, or to generate a new Move project by using sui move new project_name, which creates the needed directories and the Move.toml file.

Check Sui CLI installation

Before you can use the Sui CLI, you must install it. To check if the CLI exists on your system, open a terminal or console and type the following command:

$ sui --version

If the terminal or console responds with a version number, you already have the Sui CLI installed.

If the command is not found, follow the instructions in Install Sui to get the Sui CLI on your system.

Commands

$ sui move --help

Examples

The following examples demonstrate some of the most often used commands.

Create a new Move project

To create a new Move project that automatically adds the necessary dependencies in a Move.toml file, run sui move new [<PROJECT-NAME>].

$ sui move new smart_contract_test
$ ls -l smart_contract_test
Move.toml
Sources

Display the contents of Move.toml file.

$ cat smart_contract_test/Move.toml
[package]
name = "smart_contract_test"
version = "0.0.1"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }

[addresses]
smart_contract_test = "0x0"

Build a Move project

Use sui move build at the root of your Move project to build the package.

$ sui move build
UPDATING GIT DEPENDENCY https://github.com/MystenLabs/sui.git
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING smart_contract_test

Run tests in a Move project

Use sui move test to run the tests in a Move package.

$ sui move test
UPDATING GIT DEPENDENCY https://github.com/MystenLabs/sui.git
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING smart_contract_test
Running Move unit tests
Test result: OK. Total tests: 0; passed: 0; failed: 0

Get test coverage for a module

caution

This command currently only works on debug builds of the CLI. Please build the CLI from source to use it.

This example uses first_package Move package.

To get a summary of the test coverage, you must first run the sui move test --coverage command, and then the sui move coverage summary --test to get a summary of the test coverage in the example project.

$ sui move test --coverage
INCLUDING DEPENDENCY Sui
INCLUDING DEPENDENCY MoveStdlib
BUILDING first_package
Running Move unit tests
[ PASS ] 0x0::example::test_module_init
[ PASS ] 0x0::example::test_sword_transactions
Test result: OK. Total tests: 2; passed: 2; failed: 0

$ sui move coverage summary --test
+-------------------------+
| Move Coverage Summary |
+-------------------------+
Module 0000000000000000000000000000000000000000000000000000000000000000::example
>>> % Module coverage: 92.81
+-------------------------+
| % Move Coverage: 92.81 |
+-------------------------+

Help

Each command has its own help section. For example:

$ sui move build --help