Skip to content

getAccountAddressFromIdentifier

getAccountAddressFromIdentifier(address): IPublicIdentity["address"]

Derives an account address from a given account identifier.

address: string

The account identifier from which to derive the address.

IPublicIdentity["address"]

The original account address, derived by removing the standard prefix from the identifier.

This function extracts the actual account address from an identifier by removing the standard prefix. It assumes that the identifier begins with a predefined prefix and strips it to retrieve the original address.

const accountIdentifier = 'prefix0x1234...';
try {
const accountAddress = getAccountAddressFromIdentifier(accountIdentifier);
console.log('Account Address:', accountAddress);
} catch (error) {
console.error('Error:', error);
}

Error if the identifier does not start with the defined ACCOUNT_PREFIX.

[[ERROR_INVALID_ID_PREFIX]] if the identifier prefix is invalid.

identifier/src/Identifier.ts:617