use std::path::PathBuf;
use iota_sdk::{
client::{
constants::SHIMMER_COIN_TYPE,
secret::{stronghold::StrongholdSecretManager, SecretManager},
},
wallet::{ClientOptions, Result, Wallet},
};
const ACCOUNT_ALIAS: &str = "Alice";
const NODE_URL: &str = "https://api.testnet.shimmer.network";
const STRONGHOLD_PASSWORD: &str = "a-secure-password";
const STRONGHOLD_SNAPSHOT_PATH: &str = "vault.stronghold";
#[tokio::main]
async fn main() -> Result<()> {
let secret_manager = StrongholdSecretManager::builder()
.password(STRONGHOLD_PASSWORD)
.build(PathBuf::from(STRONGHOLD_SNAPSHOT_PATH))?;
let client_options = ClientOptions::new().with_node(NODE_URL)?;
let wallet = Wallet::builder()
.with_secret_manager(SecretManager::Stronghold(secret_manager))
.with_client_options(client_options)
.with_coin_type(SHIMMER_COIN_TYPE)
.finish()
.await?;
let mnemonic = wallet.generate_mnemonic()?;
wallet.store_mnemonic(mnemonic).await?;
let account = wallet
.create_account()
.with_alias(ACCOUNT_ALIAS.to_string())
.finish()
.await?;
let address = &account.addresses().await?[0];
println!("Address:\n{}\n", address.address());
Ok(())
}