Skip to content

getAccountAddressFromIdentifier

getAccountAddressFromIdentifier(address): IPublicIdentity["address"]

Derives an account address from a given account identifier.

Parameters

address: string

The account identifier from which to derive the address.

Returns

IPublicIdentity["address"]

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

Remarks

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.

Example

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

Throws

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

Throws

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

Source

identifier/src/Identifier.ts:580