313 stable releases

new 1.16.0 Jun 2, 2023
1.15.2 Feb 14, 2023
1.14.18 May 16, 2023
1.14.17 Mar 23, 2023
0.23.8 Feb 29, 2020

#1338 in Magic Beans

Download history 7289/week @ 2023-02-15 9832/week @ 2023-02-22 4438/week @ 2023-03-01 5029/week @ 2023-03-08 5020/week @ 2023-03-15 4374/week @ 2023-03-22 4021/week @ 2023-03-29 3903/week @ 2023-04-05 3317/week @ 2023-04-12 4422/week @ 2023-04-19 5035/week @ 2023-04-26 5746/week @ 2023-05-03 4988/week @ 2023-05-10 4123/week @ 2023-05-17 4784/week @ 2023-05-24 6252/week @ 2023-05-31

21,332 downloads per month
Used in 119 crates (40 directly)


12K SLoC

Loading and saving the Solana CLI configuration file.

The configuration file used by the Solana CLI includes information about the RPC node to connect to, the path to the user's signing source, and more. Other software than the Solana CLI may wish to access the same configuration and signer.

The default path to the configuration file can be retrieved from CONFIG_FILE, which is a lazy_static of Option<String>, the value of which is


CONFIG_FILE will only be None if it is unable to identify the user's home directory, which should not happen under typical OS environments.

The CLI configuration is defined by the [Config] struct, and its value is loaded with [Config::load] and saved with [Config::save].

Two important fields of Config are

  • json_rpc_url, the URL to pass to solana_rpc_client::rpc_client::RpcClient.
  • keypair_path, a signing source, which may be a keypair file, but may also represent several other types of signers, as described in the documentation for solana_clap_utils::keypair::signer_from_path.


Loading and saving the configuration. Note that this uses the anyhow crate for error handling.

use anyhow::anyhow;
use solana_cli_config::{CONFIG_FILE, Config};

let config_file = solana_cli_config::CONFIG_FILE.as_ref()
    .ok_or_else(|| anyhow!("unable to get config file path"))?;
let mut cli_config = Config::load(&config_file)?;
// Set the RPC URL to devnet
cli_config.json_rpc_url = "https://api.devnet.solana.com".to_string();
# Ok::<(), anyhow::Error>(())


~632K SLoC