use mesmo::{Mesmo, Network};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let lib = Mesmo::new()?;
let created = lib.accounts().create(Network::Testnet)?;
let info = created.info()?;
let mnemonic = created.export_recovery_phrase()?;
let base_address = info["base_address"].as_str().unwrap().to_string();
println!("Created account");
println!(" base address: {}", base_address);
println!(" DRep ID : {}", info["drep_id"].as_str().unwrap());
println!(" mnemonic : {}", mnemonic);
let restored = lib.accounts().from_mnemonic(&mnemonic, Network::Testnet, 0, 0)?;
let restored_info = restored.info()?;
assert_eq!(restored_info["base_address"].as_str().unwrap(), base_address);
println!("Restored from mnemonic — address matches: {}", base_address);
let key_json = lib.crypto().derive_key(&mnemonic, 0, 0, "payment")?;
let key: serde_json::Value = serde_json::from_str(&key_json)?;
println!(" private key (extended, hex): {}", key["private_key"].as_str().unwrap());
println!(" public key (hex) : {}", key["public_key"].as_str().unwrap());
Ok(())
}