Umbra SDK Docs

generateRandomFeesConfigurationAccountOffset

Umbra SDK reference for Generate Random Fees Configuration Account Offset.

client


generateRandomFeesConfigurationAccountOffset(_instructionSeed, _mintAddress): U16

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

Generates a cryptographically secure random offset for selecting a fees configuration 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 fees configuration account from multiple available configurations. The offset is used to derive the Program Derived Address (PDA) for the selected configuration 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 fees configuration 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 configuration account PDA.

Example

// Generate a random offset for fees configuration account selection
const offset = generateRandomFeesConfigurationAccountOffset(instructionSeed, mintAddress);
// Use the offset to derive the configuration account address
const configAccount = deriveFeesConfigurationAccount(offset);