See Java API for more on key addresses.

Constructing KeyAddress

Usually, you get it from publicKey.shortAddress, publicKey.longAddress or corresponding properties of the provate key, which just get the public key properties.

from packed binary

let keyAddress = new KeyAddress(packed);
  • packed should be a Uint8Array instance with binary packed data.

from string

String representation uses a special encoding, safe58 to get non ambigous representation of the binary packed form. The packed property of the KeyAddress returns a binary backed address.

let keyAddress = new KeyAddress(string);
  • packed should be a valid string representation. Use toString() to get it.

String representation

let addressString = keyAddress.toString();

returns just as expected, Universa safe58 represetnation of the KeyAddress.

Binary packed representation

let addressString = keyAddress.packed;

returns Universa binary represntation of the KeyAddress in the Unit8Array form.

Check the key is matching

let ska = publicKey.shortAddress;
let lka = publicKey.shortAddress;