Umbra SDK Docs

generateRandomPublicCommissionFeesAccountOffset

Umbra SDK reference for Generate Random Public Commission Fees Account Offset.

client


generateRandomPublicCommissionFeesAccountOffset(_instructionSeed, _mintAddress): U16

Defined in: src/utils/miscellaneous.ts:381

Generates a cryptographically secure random offset for selecting a public commission fees account.

Parameters

_instructionSeed

U16

The instruction seed (currently unused, reserved for future deterministic generation)

_mintAddress

MintAddress

The mint address of the token (currently unused, reserved for future deterministic generation)

Returns

U16

A random 16-bit unsigned integer (U16) account offset within the valid range

Throws

AccountOffsetGenerationError When random generation fails or conversion errors occur

Remarks

This function generates a random offset used to select a specific public commission fees account from multiple available accounts. The offset is used to derive the Program Derived Address (PDA) for the selected public commission fees account.

Security: This function uses cryptographically secure random number generation to ensure the offset is unpredictable and cannot be manipulated by attackers.

Current Implementation: Currently, there is only one public commission fees account (NUMBER_OF_ACCOUNTS = 1), so this function will always return 0. The parameters _instructionSeed and _mintAddress are currently unused but reserved for future deterministic generation based on instruction context and token type.

Account Offset: The returned offset is a 16-bit unsigned integer (U16) that must be less than the number of available accounts. It's used as part of the seed derivation for the public commission fees account PDA.

Example

// Generate a random offset for public commission fees account selection
const offset = generateRandomPublicCommissionFeesAccountOffset(instructionSeed, mintAddress);
// Use the offset to derive the public commission fees account address
const publicCommissionAccount = derivePublicCommissionFeesAccount(offset);