Skip to main content

Generate Addresses

You can generate an IOTA address using the Client.get_addresses() function that will return a list of tuples with the generated addresses.

The following code example will:

  1. Create a Client which will connect to the Shimmer Testnet.
  2. Create a SecretManager from a mnemonic.
  3. Generate a public address.
  4. Generate an internal address.
  5. Generate an offline address.

You can also find this guide in the native iota.js library

Code Example


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

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

//! cargo run --example generate_addresses --release -- [NODE URL]

use iota_client::{
secret::{mnemonic::MnemonicSecretManager, SecretManager},
Client, Result,

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

// Take the node URL from command line argument or use one from env as default.
let node_url = std::env::args()
.unwrap_or_else(|| std::env::var("NODE_URL").unwrap());

// Create a client instance
let client = Client::builder()
.with_node(&node_url)? // Insert your node URL here

let secret_manager = SecretManager::Mnemonic(MnemonicSecretManager::try_from_mnemonic(

// Generate addresses with default account index and range
let addresses = client.get_addresses(&secret_manager).finish().await?;

println!("List of generated public addresses:\n{addresses:#?}\n");

// Generate addresses with custom account index and range
let addresses = client

println!("List of generated public addresses:\n{addresses:#?}\n");

// Generating addresses with `client.get_addresses(&secret_manager)`, will by default get the bech32_hrp (Bech32
// human readable part) from the node info, generating it "offline" requires setting it with
// `with_bech32_hrp(bech32_hrp)`
let addresses = GetAddressesBuilder::new(&secret_manager)

println!("List of offline generated public addresses:\n{addresses:#?}\n");


Run the Example

Run the example by running the following command:

cargo run --example generate_addresses --release --
  • You can replace with any node url.

Expected Output

First public address: rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy