Sui Client CLI
The Sui CLI client
command provides command-level access to interact with the Sui network. Typical uses for sui client
include publishing Move smart contracts, getting the information of an object, executing transactions, or managing addresses.
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
The following list itemizes all the available subcommands for the sui client
command.
Usage: sui client [OPTIONS] [COMMAND]
Commands:
active-address Default address used for commands when none specified
active-env Default environment used for commands when none specified
addresses Obtain the Addresses managed by the client
balance List the coin balance of an address
call Call Move function
chain-identifier Query the chain identifier from the rpc endpoint
dynamic-field Query a dynamic field by its address
envs List all Sui environments
execute-signed-tx Execute a Signed Transaction. This is useful when the user prefers to sign elsewhere and use this command to execute
execute-combined-signed-tx Execute a combined serialized SenderSignedData string
faucet Request gas coin from faucet. By default, it will use the active address and the active network
gas Obtain all gas objects owned by the address. An address' alias can be used instead of the address
merge-coin Merge two coin objects into one coin
new-address Generate new address and keypair with keypair scheme flag {ed25519 | secp256k1 | secp256r1} with optional derivation path, default to m/44'/784'/0'/0'/0' for ed25519 or m/54'/784'/0'/0/0
for secp256k1 or m/74'/784'/0'/0/0 for secp256r1. Word length can be { word12 | word15 | word18 | word21 | word24} default to word12 if not specified
new-env Add new Sui environment
object Get object info
objects Obtain all objects owned by the address. It also accepts an address by its alias
pay Pay coins to recipients following specified amounts, with input coins. Length of recipients must be the same as that of amounts
pay-all-sui Pay all residual SUI coins to the recipient with input coins, after deducting the gas cost. The input coins also include the coin for gas payment, so no extra gas coin is required
pay-sui Pay SUI coins to recipients following following specified amounts, with input coins. Length of recipients must be the same as that of amounts. The input coins also include the coin for
gas payment, so no extra gas coin is required
publish Publish Move modules
split-coin Split a coin object into multiple coins
switch Switch active address and network(e.g., devnet, local rpc server)
tx-block Get the effects of executing the given transaction block
transfer Transfer object
transfer-sui Transfer SUI, and pay gas with the same SUI coin object. If amount is specified, only the amount is transferred; otherwise the entire object is transferred
upgrade Upgrade Move modules
verify-bytecode-meter Run the bytecode verifier on the package
verify-source Verify local Move packages against on-chain packages, and optionally their dependencies
profile-transaction Profile the gas usage of a transaction. Unless an output filepath is not specified, outputs a file `gas_profile_{tx_digest}_{unix_timestamp}.json` which can be opened in a flamegraph
tool such as speedscope
replay-transaction Replay a given transaction to view transaction effects. Set environment variable MOVE_VM_STEP=1 to debug
replay-batch Replay transactions listed in a file
replay-checkpoint Replay all transactions in a range of checkpoints
help Print this message or the help of the given subcommand(s)
Options:
--client.config <CONFIG> Sets the file storing the state of our user accounts (an empty one will be created if missing)
--json Return command outputs in json format
-y, --yes
-h, --help Print help
JSON output
Append the --json
flag to commands to format responses in JSON instead of the more human-friendly default Sui CLI output. This can be useful for extremely large datasets, for example, as those results can have a troublesome display on smaller screens. In these cases, the --json
flag is useful.
Examples
The following examples demonstrate some of the most often used commands.
List available network environments
Use the sui client envs
command to find the network environments set up in the CLI. The information for these environments is also stored in the client.yaml file in the Sui configuration directory (~/.sui/sui_config
).
╭─── ─────┬────────────────────────────────────┬────────╮
│ alias │ url │ active │
├────────┼────────────────────────────────────┼────────┤
│ devnet │ https://fullnode.devnet.sui.io:443 │ * │
╰────────┴────────────────────────────────────┴────────╯
Create network environment
Use client new-env
to add details for a new network environment. This example creates an environment pointer to Sui Mainnet. Setting the alias
value makes referencing the environment less prone to typographical errors. After running this command, Sui updates your client.yaml file in ~/.sui/sui_config
with the new information.
$ sui client new-env --alias=mainnet --rpc https://fullnode.mainnet.sui.io:443
Added new Sui env [mainnet] to config.
Set current environment
Use the sui client switch
command to change the current network. This example switches the current network to mainnet
.
$ sui client switch --env mainnet
Active environment switched to [mainnet]
If you run sui client envs
after this command, you see the asterisk in the active
column on the mainnet
row of the table.
Get current active address
Use the sui client active-address
command to reveal the current address. The CLI uses the current active address to execute address-specific CLI commands (like sui client objects
) when you don't provide them with a Sui address value.
$ sui client active-address
0x514692f08249c3e9951234ce29074695840422564bff85e424b56de462913e0d
Request a SUI coin from faucet
If you use one of the standard public RPCs (for example, fullnode.testnet.sui.io:443
), you can use the faucet
command to request gas coins. If you use a custom faucet service, then pass in the URL to the faucet using the --url
option.
$ sui client faucet
Request successful. It can take up to 1 minute to get the coin. Run sui client gas to check your gas coins.
Get objects owned by an address
Use sui client objects
to list summary information about the objects the current active address owns. You can provide a Sui address value to the command to list objects for a particular address. This example lists objects for the current active address.
$ sui client objects 0x36df11369cf00ecf0be68d6ba965b0abe2e883bc5245911e3a29ebfa0aaf6b69
╭───────────────────────────────────────────────────────────────────────────────────────╮
| ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ 0xfffbb30ccb631f15f6cd36700589fc9c31cb04af28a95f3ed26d62daf3acb57f │ │
│ │ version │ 33363559 │ │
│ │ digest │ IY7/qsIJhliQL0uxwSzNYu0SMcn5AMsqQklSGngn1V0= │ │
│ │ objectType │ 0x0000..0002::coin::Coin │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
│ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │
│ │ objectId │ 0xfffe59fb6f78b1ced7f6537e69a205cc45d105270857bfd66332f9a627a38ae0 │ │
│ │ version │ 33370864 │ │
│ │ digest │ b+tKChvujbCk/UCm8L+lflyb6Vjt7beB+uz6+ahUHmM= │ │
│ │ objectType │ 0x0000..0002::coin::Coin │ │
│ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │
╰───────────────────────────────────────────────────────────────────────────────────────╯
Get complete object information
Use sui client object <OBJECT-ID>
to list object information for the ID you provide. This example displays the information for a Coin object.
$ sui client object 0xfffbb30ccb631f15f6cd36700589fc9c31cb04af28a95f3ed26d62daf3acb57f
╭───────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ objectId │ 0xfffbb30ccb631f15f6cd36700589fc9c31cb04af28a95f3ed26d62daf3acb57f │
│ version │ 33363559 │
│ digest │ 3FzvXJVVVcXb9H6dEXdARaY9EmxXyyNFduet3X4eYV4x │
│ objType │ 0x2::coin::Coin<0x2::sui::SUI> │
│ ownerType │ AddressOwner │
│ prevTx │ ES2RQThjRE5u8rwiUEnhcnMoLA3cHeEGYJ8Pq98tmyAc │
│ storageRebate │ 988000 │
│ content │ ╭───────────────────┬─────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ │ dataType │ moveObject │ │
│ │ │ type │ 0x2::coin::Coin<0x2::sui::SUI> │ │
│ │ │ hasPublicTransfer │ true │ │
│ │ │ fields │ ╭─────────┬───────────────────────────────────────────────────────────────────────────────╮ │ │
│ │ │ │ │ balance │ 530076676 │ │ │
│ │ │ │ │ id │ ╭────┬──────────────────────────────────────────────────────────────────────╮ │ │ │
│ │ │ │ │ │ │ id │ 0xfffbb30ccb631f15f6cd36700589fc9c31cb04af28a95f3ed26d62daf3acb57f │ │ │ │
│ │ │ │ │ │ ╰────┴──────────────────────────────────────────────────────────────────────╯ │ │ │
│ │ │ │ ╰─────────┴───────────────────────────────────────────────────────────────────────────────╯ │ │
│ │ ╰───────────────────┴─────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰───────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Get dynamic fields of an object
Use the sui client dynamic-field <DYNAMIC-FIELD-ID>
command to list the details of the dynamic field with the ID you provide.
$ sui client dynamic-field 0x5
╭─────────────┬───────────────────────────────────────────────────────────────────────────────────────────╮
│ hasNextPage │ false │
│ nextCursor │ 0x5b890eaf2abcfa2ab90b77b8e6f3d5d8609586c3e583baf3dccd5af17edf48d1 │
│ data │ ╭───────────────────────────────────────────────────────────────────────────────── ──────╮ │
│ │ │ ╭────────────┬──────────────────────────────────────────────────────────────────────╮ │ │
│ │ │ │ name │ ╭───────┬───────╮ │ │ │
│ │ │ │ │ │ type │ u64 │ │ │ │
│ │ │ │ │ │ value │ 2 │ │ │ │
│ │ │ │ │ ╰───────┴───────╯ │ │ │
│ │ │ │ bcsName │ LQM2cdzDY3 │ │ │
│ │ │ │ type │ DynamicField │ │ │
│ │ │ │ objectType │ 0x3::sui_system_state_inner::SuiSystemStateInnerV2 │ │ │
│ │ │ │ objectId │ 0x5b890eaf2abcfa2ab90b77b8e6f3d5d8609586c3e583baf3dccd5af17edf48d1 │ │ │
│ │ │ │ version │ 112 │ │ │
│ │ │ │ digest │ HMrm1KNKjq3GfB1cWTRdvRo8gk7auhgvoZXaVoyEHqUR │ │ │
│ │ │ ╰────────────┴──────────────────────────────────────────────────────────────────────╯ │ │
│ │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ │
╰─────────────┴───────────────────────────────────────────────────────────────────────────────────────────╯
Send SUI or objects
In this example, let's see how to transfer SUI or transfer an object from one address to another. First of all, there two main commands for sending SUI or transferring objects: pay
and transfer
.
Both pay
and transfer
have a few sister commands: pay-sui
, pay-all-sui
, transfer-sui
.
The differences between these commands are:
- commands that end in
-sui
deal with Sui's native coin, and they use the input coints to pay for gas and for transferring SUI or the object. pay-
commands typically deal with coins and handle gas smashing for you, whereastransfer
commands can handle the transfer of any object that has public transfer, meaning any object that has thestore
ability.pay
commands allow you to send coins to multiple recipients, whereastransfer
commands only accept one recipient.pay-all-sui
is a special case ofpay-sui
that offers a way to transfer the entire balance after smashing.transfer-sui
is a legacy command and has been entirely superseded bypay-sui
orpay-all-sui
depending on whether an amount is specified or not.
Assume you have two addresses:
╭───────────────────┬────────────────────────────────────────────────────────────────────┬────────────────╮
│ alias │ address │ active address │
├───────────────────┼────────────────────────────────────────────────────────────────────┼────────────────┤
│ hungry-spodumene │ 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea │ * │
│ eloquent-amber │ 0x3d78abc33ccd173c521b4f9e78b21ea2c989960b631732c539efaa38bda30976 │ │
╰───────────────────┴────────────────────────────────────────────────────────────────────┴──────────── ────╯
Address hungry-spodumene
has a few coins:
sui client gas hungry-spodumene
╭────────────────────────────────────────────────────────────────────┬────────────────────┬──────────────────╮
│ gasCoinId │ mistBalance (MIST) │ suiBalance (SUI) │
├────────────────────────────────────────────────────────────────────┼────────────────────┼──────────────────┤
│ 0x205972830acd8264a38b9a1776a1b72a1ae626fa23a4d1f12249349ce3b83c06 │ 200000000000 │ 200.00 │
│ 0x56d76420a5bc7d356e3930e6a2ddc61cbbc0c87ea5c5f3cc3ac5952b4d52be5a │ 200000000000 │ 200.00 │
│ 0xc9b447fff18f13fa035e028534b8344d5fc8a8760248fad10155e78f44dc3a52 │ 200000000000 │ 200.00 │
│ 0xe373de9bdbd3dbd4f5f707f144c83af74a181cdb3903a953ee366f48e33865c7 │ 200000000000 │ 200.00 │
│ 0xf7adb6aeb18eb409c03fe88cc31711b61a65333e0fdd88c1815d4ec75f713f31 │ 200000000000 │ 200.00 │
╰────────────────────────────────────────────────────────────────────┴────────────────────┴──────────────────╯
You want to send 0.5 SUI to eloquent-amber
. Given that you have a few gas coins, you can use pay
. If only one gas coin exists, then you need to use transfer-sui
or pay-sui
, or you would need to split the coin first to have another coin to use for paying gas. In this case, let's use the pay-sui
command as you do not need to provide a separate gas coin to be used for the gas fees. In the command below, you set the recipient to be eloquent-amber
, which coin to use to transfer SUI from, and the amount of SUI to transfer.
Beginning with the Sui v1.24.1
release, the --gas-budget
flag is no longer required for CLI commands.
sui client pay-sui --recipients eloquent-amber --input-coins 0xc9b447fff18f13fa035e028534b8344d5fc8a8760248fad10155e78f44dc3a52 --amounts 500000000 --gas-budget 5000000
The result is:
Transaction Digest: AsWkciVhLHeCmqVipjjyAA7Hv5y87pFjHS59K8m4zBJV
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Transaction Data │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Sender: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea │
│ Gas Owner: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea │
│ Gas Budget: 5000000 MIST │
│ Gas Price: 1000 MIST │
│ Gas Payment: │
│ ┌── │
│ │ ID: 0xc9b447fff18f13fa035e028534b8344d5fc8a8760248fad10155e78f44dc3a52 │
│ │ Version: 2 │
│ │ Digest: 9MEH7kr1YkBDx7pdUPCDnVb3FtPz9UZVeWmCot5Dhxqr │
│ └── │
│ │
│ Transaction Kind: Programmable │
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ Input Objects │ │
│ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │
│ │ 0 Pure Arg: Type: address, Value: "0x3d78abc33ccd173c521b4f9e78b21ea2c989960b631732c539efaa38bda30976" │ │
│ │ 1 Pure Arg: Type: u64, Value: "500000000" │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ ╭──────────────────────╮ │
│ │ Commands │ │
│ ├──────────────────────┤ │
│ │ 0 SplitCoins: │ │
│ │ ┌ │ │
│ │ │ Coin: GasCoin │ │
│ │ │ Amounts: │ │
│ │ │ Input 1 │ │
│ │ └ │ │
│ │ │ │
│ │ 1 TransferObjects: │ │
│ │ ┌ │ │
│ │ │ Arguments: │ │
│ │ │ Result 0 │ │
│ │ │ Address: Input 0 │ │
│ │ └ │ │
│ ╰──────────────────────╯ │
│ │
│ Signatures: │
│ eZc/iFO3i4Y8Le92zu9q75jILs+yg0sSXd1yPV9Dta+knH99VfkSCnzNQG1KbXSvY24wexmVtiuU6NkfudbiAQ== │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────────────────────────────────────────────────── ────────╮
│ Transaction Effects │
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Digest: AsWkciVhLHeCmqVipjjyAA7Hv5y87pFjHS59K8m4zBJV │
│ Status: Success │
│ Executed Epoch: 0 │
│ │
│ Created Objects: │
│ ┌── │
│ │ ID: 0xa031d3f8fd53b5f9885172e1c6bd8b770b25e42371c9ee215c6d4b21b2b73241 │
│ │ Owner: Account Address ( 0x3d78abc33ccd173c521b4f9e78b21ea2c989960b631732c539efaa38bda30976 ) │
│ │ Version: 3 │
│ │ Digest: Fq3maqq3pShgKw58Ssm8cS2j1pspfhanedVK2MMxfQWQ │
│ └── │
│ Mutated Objects: │
│ ┌── │
│ │ ID: 0xc9b447fff18f13fa035e028534b8344d5fc8a8760248fad10155e78f44dc3a52 │
│ │ Owner: Account Address ( 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea ) │
│ │ Version: 3 │
│ │ Digest: GFB9mpxTP4z6CCShTbvD58FYxtu9G4mnxN3JtFeRupM3 │