Configure a Sui Client
The Sui client configuration specifies which network to connect to and which address to send transactions. When you run sui client for the first time, it generates a key pair, writes a client.yaml file to your local config directory, and sets Testnet as the active environment. You can switch networks, add custom RPC endpoints, and manage multiple environments using the sui client new-env and sui client switch subcommands.
- Prerequisites
First, confirm that Sui has been installed successfully:
$ sui --version
If this command returns sui not found, then Sui is not installed and you must follow the installation instructions.
sui client
Run the Sui CLI with the command:
$ sui client
If a previous Sui installation stored a client.yaml file locally, you receive the sui client --help output in the console. You can delete the existing ~/.sui/sui_config/client.yaml file if you'd like to start fresh, or you can continue using the existing configuration.
The prompt asks if you want to create the client.yaml file, select Y or press enter. You can skip the prompt with sui client -y.
No sui config found in `~/.sui/sui_config/client.yaml`, create one [Y/n]?
You see the following output:
Generated new keypair ...
secret recovery phrase : [recovery phrase words are here]
Created "~/.sui/sui_config/client.yaml"
Set active environment to testnet
Store recovery phrases securely and do not share them with anyone, as they provide access to any objects and tokens that an address owns.
The recovery phrase is not visible again once the CLI history disappears.
Learn more about Sui addresses, key generation, and recovery phrases.
How do I switch between Sui Testnet, Devnet, and Mainnet?
Use sui client switch to change the active network environment:
$ sui client switch --env testnet
To list all configured environments and see which one is currently active, run:
$ sui client envs
You see output similar to:
localnet => http://0.0.0.0:9000 (active)
devnet => https://fullnode.devnet.sui.io:443
testnet => https://fullnode.testnet.sui.io:443
mainnet => https://fullnode.mainnet.sui.io:443
To add a new environment, use sui client new-env. For example, to add a custom RPC endpoint:
$ sui client new-env --alias custom --rpc https://your-custom-rpc-url
After adding the environment, switch to it with sui client switch --env custom.
What is client.yaml and how do I edit it?
Your Sui client is now configured. By default, Sui stores this information in either the ~/.sui/sui_config/client.yaml file (macOS/Linux) or %USERPROFILE%\.sui\sui_config\client.yaml file (Windows). You can store a client.yaml file in a different location, if preferred, and specify its location with the --client.config flag.
The client.yaml contains the configuration for connecting to different Sui networks (Testnet, Mainnet, Devnet, and Localnet), as well as your current active environment, which tells the CLI which network to use when you don't explicitly specify one.
You can modify your configuration using the sui client subcommands. See the output of sui client --help for more information.
Sui stores the key for the Sui address in a separate file, ~/.sui/sui_config/sui.keystore (macOS/Linux) or %USERPROFILE/.sui/sui_config/sui.keystore (Windows). Learn more about Sui addresses in Create a Sui Address.