Skip to main content

Create a Wallet Account

The first thing you will need to do when you are getting started with the library is to create a wallet account.

Account Approaches

Code Example

The following example will:

  1. Create an account manager.
  2. Use it to store the Stronghold mnemonic.
  3. Create a wallet with the alias "Alice".

This example uses dotenv, which is not safe for use in production environments.

// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

//! cargo run --example create_wallet --release
// In this example we will create a new wallet
// Rename `.env.example` to `.env` first

use std::{env, path::PathBuf};

use dotenv::dotenv;
use iota_wallet::{
secret::{stronghold::StrongholdSecretManager, SecretManager},
ClientOptions, Result,

async fn main() -> Result<()> {
// This example uses dotenv, which is not safe for use in production

// Setup Stronghold secret_manager
let mut secret_manager = StrongholdSecretManager::builder()

// Only required the first time, can also be generated with `manager.generate_mnemonic()?`
let mnemonic = env::var("NON_SECURE_USE_OF_DEVELOPMENT_MNEMONIC").unwrap();

// The mnemonic only needs to be stored the first time

// Create the account manager with the secret_manager and client options
let client_options = ClientOptions::new().with_node(&env::var("NODE_URL").unwrap())?;

let manager = AccountManager::builder()

// Create a new account
let _account = manager

println!("Generated a new account");


Run the Example

Run the example by running the following command:

cargo run --example create_wallet --release

Expected Output

Generated a new account