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
- Rust
- Go
- Python
- Kotlin
- Swift
- Define the mnemonic string.
- Derive the Ed25519 key pair and address from the mnemonic.
- Derive the Secp256k1 key pair and address.
- Derive the Secp256r1 key pair and address using a custom derivation path.
- Define the mnemonic string.
- Derive the Ed25519 key pair and address from the mnemonic.
- Derive the Secp256k1 key pair and address.
- Derive the Secp256r1 key pair and address using a custom derivation path.
- Define the mnemonic string.
- Derive the Ed25519 key pair and address from the mnemonic.
- Derive the Secp256k1 key pair and address.
- Derive the Secp256r1 key pair and address using a custom derivation path.
- Define the mnemonic string.
- Derive the Ed25519 key pair and address from the mnemonic.
- Derive the Secp256k1 key pair and address.
- Derive the Secp256r1 key pair and address using a custom derivation path.
- Define the mnemonic string.
- Derive the Ed25519 key pair and address from the mnemonic.
- Derive the Secp256k1 key pair and address.
- Derive the Secp256r1 key pair and address using a custom derivation path.
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
- Rust
- Go
- Python
- Kotlin
- Swift
crates/iota-sdk/examples/address_from_mnemonic.rs
loading...
bindings/go/examples/address_from_mnemonic/main.go
loading...
bindings/python/examples/address_from_mnemonic.py
loading...
bindings/kotlin/examples/AddressFromMnemonic.kt
loading...
bindings/swift/examples/AddressFromMnemonic.swift
loading...