Setup CLI Initial Configuration
If you are using the CLI to try things out on-chain, you will need to configure the network, faucet, and credentials you want the CLI to use.
This makes using the CLI easier and more secure as you will not be forced to repeatedly copy addresses or private keys.
If you still need to install the CLI, follow these steps.
- Run
aptos init
and follow the instructions in the command line.
To use default settings, you can provide no input and just press “Enter”. For example:
aptos init
Configuring for profile default
Enter your rest endpoint [Current: None | No input: https://api.devnet.aptoslabs.com]
No rest url given, using https://api.devnet.aptoslabs.com...
Enter your faucet endpoint [Current: None | No input: https://faucet.devnet.aptoslabs.com]
No faucet url given, using https://faucet.devnet.aptoslabs.com...
Enter your private key as a hex literal (0x...) [Current: None | No input: Generate new key (or keep one if present)]
No key given, generating key...
Account 00f1f20ddd0b0dd2291b6e42c97274668c479bca70f07c6b6a80b99720779696 doesn't exist, creating it and funding it with 10000 coins
Aptos is now set up for account 00f1f20ddd0b0dd2291b6e42c97274668c479bca70f07c6b6a80b99720779696! Run `aptos help` for more information about commands
{
"Result": "Success"
}
- Later, if you want to update these settings, you can do so by running
aptos init
again. - The rest of these configuration steps are optional / quality of life. To continue to use the CLI for your specific use case, follow the usage guide here.
(Optional) Creating Named Configurations (Profiles)
For testing more complicated scenarios, you will often want multiple accounts on-chain. One way to do this is to create a named configuration which we call a profile.
To create a profile, run aptos init --profile <name_of_profile>
. The configuration you generate will be usable when calling CLI commands as replacements for arguments.
For example:
aptos init --profile bob
...
aptos account fund-with-faucet --profile bob
{
"Result": "Added 100000000 Octas to account 0x63169727b08fc137b8720e451f7a90584ccce04c301e151daeadc7b8191fdfad"
}
(Optional) Setting Up Shell Completion
One quality of life feature you can enable is shell auto-completions.
- Determine which shell you are using (you can run
echo $SHELL
if you are unsure). - Look up where configuration files for shell completions go for that shell (it varies from shell to shell). The supported shells are
[bash, zsh, fish, PowerShell, elvish]
. - Run the following command with your specific shell and the output file for completions using your shell:
aptos config generate-shell-completions --shell <YOUR_SHELL_HERE> --output-file <OUTPUT_DESTINATION_FOR_YOUR_SHELL>
Example command for oh my zsh
:
aptos config generate-shell-completions --shell zsh --output-file ~/.oh-my-zsh/completions/_aptos
(Optional) Global Config
By default, the CLI will look for a configuration in .aptos/config.yaml
in each workspace directory. If you would like to use a shared configuration for all workspaces, you can follow these steps:
- Create a folder in your home directory called
.aptos
(so it has the path~/.aptos
). - Create a yaml file inside
.aptos
calledglobal_config.yaml
. - Run the command:
aptos config set-global-config --config-type global
You should see:
{
"Result": {
"config_type": "Global"
}
}