Skip to main content
Version: IOTA

Generate Addresses

Example Seed

The examples use an example seed b3d7092195c36d47133ff786d4b0a1ef2ee6a0052f6e87b6dc337935c70c531e that is stored in an environment variable called IOTA_SEED_SECRET. This seed serves for training purposes only.

You can generate an IOTA address using the GetAddressesBuilder helper class and calling the GetAddressesBuilder::from(seed: &str) function and respective chaining calls that will return a list of tuples with the generated addresses. You can find more information on the parameters in the Address/Key Space section.

The whole process is deterministic. This means the output is the same as long as the seed is the same:

public static void generateAddresses() {
try {
Client iota = node();

String seed = RustHex.encode("NONSECURE_USE_OF_DEVELOPMENT_SEED_1");
String[] addresses = GetAddressesBuilder.from(seed).withClient(iota).withRange(0, 10).finish();
System.out.println(Arrays.toString(addresses));
} catch (ClientException e) {
System.out.println("Error: " + e.getMessage());
}
}


Output example:

[
'atoi1qz6dr6dtl0856tf0pczz7gesrf7j8a4vr00q58ld2zx7ttlv3p96snpym9z',
'atoi1qpp7sz28a0ghvd6knwnljr7j2s04qquduuc5vlz94fwf94zznj2yv5ew2c4',
'atoi1qzje6zhg5vu456eg3z84ekcfn3laxqyczche5eeqhcdh3w9yr5sqvr4z4td',
'atoi1qqwhxjmcvmatpedeedapgx0vwyupfwx9k5n4w0lnc5l6vmz78aavwhs55v0',
'atoi1qzg63t9880jtfysvpq7rrynz0rqt3kd2fw8r4934ezraz9dpwvzxkw2dtmh'
]

IOTA addresses are represented by a checksumed base-32 string (Bech32). You can find a detailed explanation in the Chrysalis documentations, but here are parts relevant to this example:

  • If an address starts with atoi then it means it is related to devnet. iota stands for mainnet.
  • Number 1 at the 5th position is just a separator.
  • The last 6 characters are reserved for a checksum.

Addresses can be also represented in a hex format using the Client.bech32ToHex(bech32) function.

If you want to quickly validate any IOTA address, you can use the Client.isAddressValid() function that returns a bool value. You should perform a sanity check on address before using it.