Skip to main content

Create a Snapshot

Run the Example

You can create a new snapshot on the file system, and generate and store a new Ed25519 key inside the desired location by running the following command from within the client crate.

cargo run --example cli create-snapshot --path "/path/to/snapshot.file" --client-path "client-path-0" --vault-path "vault-path" --record-path "record-path" --key "passphrase"

Expected Output

[2022-06-28T14:27:05Z INFO  cli] Snapshot created successully? true

Example Code

async fn command_create_snapshot(path: String, client_path: String, output: VaultLocation, key: String) {
let stronghold = Stronghold::default();

let client_path = client_path.as_bytes().to_vec();

let client = stronghold
.expect("Cannot creat client");

let output_location = output.to_location();

let generate_key_procedure = GenerateKey {
ty: KeyType::Ed25519,
output: output_location,

.expect("Running procedure failed");

.expect("Store client state into snapshot state failed");

// calculate hash from key
let key = hash_blake2b(key);
"Snapshot created successully? {}",
.commit_with_keyprovider(&SnapshotPath::from_path(path), &KeyProvider::try_from(key).unwrap())