This guide describes how to use the Diem command line interface (CLI) client to interact with the Diem Blockchain’s testnet. The CLI is invoked as an interactive shell. It provides basic commands to simulate the creation of accounts, the minting of Diem Coins, performing transfers, and querying the blockchain. You can use the CLI client to interact with a validator node in different types of networks such as testnet, a local test validator network, or on a remote blockchain by specifying the node's hostname.
You can also try out our interactive Diem CLI tutorial. It's a fully functioning terminal connected to the Diem testnet.
There are two ways to invoke the Diem CLI client:
- Connect to testnet via the CLI client
- Run a CLI client to connect to any Diem network
To connect to the testnet through the CLI, a convenience script can be used to invoke the CLI without needing to specify parameters. To invoke this, change to the
diem directory and run:
To invoke the CLI client and configure it yourself, run:
The options for running the CLI client command to connect to any Dien network are:
|If set, the client will use the waypoint parameter for its initial LedgerInfo verification.|
|The URL to retrieve the waypoint from, if the waypoint parameter is not passed.|
|If set, the client will produce verbose output.|
Once started with any of the three commands previously mentioned, the following CLI commands are available:
If you enter only the major command, it will show the help information for that command. Major commands can be any one of the following:
account | a — Account related operations. Subcommands include:#
create | c — Create a random account with private/public key pair. Account information will be held in memory only. The created account will not be saved to the chain. Returns reference ID to use in other operations.
list | la — Print all accounts that were created or loaded.
recover | r — Recover all accounts that were written to a file via the
account write command.
write | w — Save Diem wallet mnemonic recovery seed to disk. This will allow accounts to be recovered via
<mint | m> | <mintb | mb> — Mint coins to the account. Creates an account at the recipient address if one does not already exist. Suffix 'b' is for blocking. If blocking is specified (using suffix 'b'), CLI will query chain until the transaction is finalized/available. Same is true for other sub "blocking" commands.
<addc | ac> | <addcb | acb> — Add specified currency to the account. Suffix 'b' is for blocking.
<transfer | t> | <transferb | tb> — Transfer coins from one account to another. Suffix 'b' is for blocking.#
query | q — Query data from destination chain. All query operations are blocking. Subcommands include:#
balance | b — Get the current balance of an account
sequence | s — Get the current sequence number for an account, and reset current sequence number in CLI (optional, default is false).
account_state | as — Get the latest state for an account.
txn_acc_seq | ts — Get the committed transaction by account and sequence number.
txn_range | tr — Get the committed transactions by version range. Optionally also fetch events emitted by these transactions.
event | ev — Get events by account and event type (sent|received).
account_resources | ar — Get the latest annotated resources in an account.
Note: This command can only be used on a local network, it cannot be used on testnet.
compile | c — Compile a Move program.
publish | p — Publish a Move module on testnet.
execute | e — Execute custom Move transaction script.
upgrade_stdlib | u — Upgrade the move stdlib used for the blockchain.
gen_waypoint | g — Generate a waypoint for the latest epoch change LedgerInfo.
change_diem_version | v — Change the diem_version stored on chain.
enable_custom_script | s — Allow executing arbitrary script in the network. This disables script hash verification.
add_to_script_allow_list | a — Add a script hash to the allow list. This enables script hash verification.
info | i — Print CLI config and client internal information.
quit | q! — Exits the CLI. No subcommand is required.
help | h — Prints help. No subcommand is required.
Account creation provided by the CLI generates a local keypair, but nothing is created on the testnet blockchain. To create an account on tesnet:
- Transfer fake Diem Coins to the address you wish to create. If the recipient account does not exist, you must create the recipient account first, and then add the specific currency into the account in order for it to receive fake Diem Coins. The sender pays a transaction fee (gas) for both account creation and transfer.
- Send a mint transaction to simulate the minting of Diem Coins to an account. If the account does not exist, the account will be created first and the fake Diem Coins will be minted later. Unlike other transactions, a nonexistent account itself can request a simulated mint transaction.