Skip to main content

derive_address

Function derive_address 

Source
pub fn derive_address(
    mnemonic_str: &str,
    account: u32,
    index: u32,
) -> Result<String, CoreError>
Expand description

Derives a bech32-encoded address from a BIP39 mnemonic at the given account and index.

Uses the MultiversX wallet derivation path: m/44’/508’/{account}‘/0’/{index}

§Arguments

  • mnemonic_str - BIP39 mnemonic phrase (12 or 24 words)
  • account - Account number in the derivation path (typically 0 for relayer, 1+ for stress testing)
  • index - Address index within the account

§Returns

The bech32-encoded address (e.g., “erd1…”), or an error if derivation fails.

§Examples

use mx_core::derive_address;

let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
let address = derive_address(mnemonic, 0, 0).unwrap();
assert!(address.starts_with("erd1"));