Skip to content

AccountIdentifier

Defined in: packages/ledger-icp/src/account_identifier.ts:23

A 32-byte account identifier used to send and receive ICP tokens.

The ICP Ledger uses the concept of an AccountIdentifier to represent accounts. It’s a unique value derived from a principal (the identity controlling the account) and a subaccount. This design allows a single principal to control multiple accounts by using different subaccounts.

toAccountIdentifierHash(): object

Defined in: packages/ledger-icp/src/account_identifier.ts:127

Returns the raw bytes wrapped in an object under the hash key.

object

{ hash: Uint8Array } where hash is the raw 32-byte Uint8Array.

hash: Uint8Array


toHex(): string

Defined in: packages/ledger-icp/src/account_identifier.ts:100

Returns the ICP Ledger Account Identifier as a 64-character hexadecimal string. This is the format typically used to display the account identifier in a human-readable way.

string

Hex representation (64-character string).


toNumbers(): number[]

Defined in: packages/ledger-icp/src/account_identifier.ts:118

Returns the account identifier as an array of numbers.

number[]

An array of byte values.


toUint8Array(): Uint8Array

Defined in: packages/ledger-icp/src/account_identifier.ts:109

Returns the raw 32-byte Uint8Array of the account identifier.

Uint8Array

The raw bytes of the account identifier.


static fromHex(hex): AccountIdentifier

Defined in: packages/ledger-icp/src/account_identifier.ts:34

Creates an AccountIdentifier object from a hexadecimal string (e.g. d3e13d4777e22367532053190b6c6ccf57444a61337e996242b1abfb52cf92c8). Validates the checksum in the process.

string

The 64-character hexadecimal representation of the account identifier.

AccountIdentifier

An instance of AccountIdentifier.

If the length is not 32 bytes or if the checksum is invalid.


static fromPrincipal(__namedParameters): AccountIdentifier

Defined in: packages/ledger-icp/src/account_identifier.ts:68

Creates an AccountIdentifier object from a principal and optional subaccount.

When no subaccount is provided, a 32-byte array of zeros is used by default. You can use any arbitrary 32 bytes as a subaccount identifier to derive a distinct account identifier for the same principal.

Principal

SubAccount = ...

AccountIdentifier

An instance of AccountIdentifier.