Skip to content

SubAccount

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

A subaccount in the ICP ledger is a 32-byte identifier that allows a principal (user or canister) to control multiple independent accounts under the same principal.

https://internetcomputer.org/docs/references/ledger#_accounts

toUint8Array(): Uint8Array

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

Returns the raw 32-byte Uint8Array representing this subaccount.

Uint8Array

A 32-byte array.


static fromBytes(bytes): SubAccount

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

Creates a SubAccount from a 32‑byte array.

Uint8Array

A Uint8Array of exactly 32 bytes.

SubAccount

A SubAccount instance.

If the byte array length is not 32.


static fromID(id): SubAccount

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

Generates a SubAccount from a non‑negative number.

The number is encoded into the last 8 bytes of the 32‑byte array. This is a common pattern when using numbered subaccounts like 0, 1, 2…

number

A non-negative integer.

SubAccount

A SubAccount instance.

If the number is negative or exceeds Number.MAX_SAFE_INTEGER.


static fromPrincipal(principal): SubAccount

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

Generates a SubAccount from a principal.

The principal is embedded into the beginning of a 32‑byte array.

Principal

A principal to encode into the subaccount.

SubAccount

A SubAccount instance.