Skip to main content

Create an Address from a Mnemonic

Alpha Software

The IOTA SDK is currently in alpha. APIs, interfaces, and behavior may change without notice between releases. It is not yet recommended for production use.

This how-to demonstrates how to derive a cryptographic key pair and an IOTA address from a BIP-39 mnemonic phrase for each of the three supported signature schemes: Ed25519, Secp256k1, and Secp256r1.

Security Warning

The mnemonic phrase used in these examples is for demonstration only. Never share or hard-code a real mnemonic in production code. Store mnemonics securely and never commit them to version control.

Prerequisites

  • The IOTA SDK installed for your target language — see Getting Started
  • A valid BIP-39 mnemonic phrase (12 or 24 words)

Example Code

  1. Define the mnemonic string.
crates/iota-sdk/examples/address_from_mnemonic.rs
loading...
  1. Derive the Ed25519 key pair and address from the mnemonic.
crates/iota-sdk/examples/address_from_mnemonic.rs
loading...
  1. Derive the Secp256k1 key pair and address.
crates/iota-sdk/examples/address_from_mnemonic.rs
loading...
  1. Derive the Secp256r1 key pair and address using a custom derivation path.
crates/iota-sdk/examples/address_from_mnemonic.rs
loading...
tip

Each scheme produces a different address from the same mnemonic. For a deeper explanation of why, see Address Derivation in IOTA.

Full Example Code

crates/iota-sdk/examples/address_from_mnemonic.rs
loading...