getAccountMetaFactory

function getAccountMetaFactory(
    programAddress,
    optionalAccountStrategy,
): (
    inputName,
    account,
) =>
    | AccountMeta<string>
    | AccountSignerMeta<string, TransactionSigner<string>>
    | undefined;

Creates a factory function that converts resolved instruction accounts to account metas.

The factory handles the conversion of ResolvedInstructionAccount objects into AccountMeta or AccountSignerMeta objects suitable for building instructions. It also determines how to handle optional accounts based on the provided strategy.

Parameters

ParameterTypeDescription
programAddressAddressThe program address, used when optional accounts use the programId strategy.
optionalAccountStrategy"omitted" | "programId"How to handle null account values: - 'omitted': Optional accounts are excluded from the instruction entirely. - 'programId': Optional accounts are replaced with the program address as a read-only account.

Returns

A factory function that converts a resolved account to an account meta.

(inputName, account):
  | AccountMeta<string>
  | AccountSignerMeta<string, TransactionSigner<string>>
  | undefined;

Parameters

ParameterType
inputNamestring
accountResolvedInstructionAccount

Returns

| AccountMeta<string> | AccountSignerMeta<string, TransactionSigner<string>> | undefined

Example

const toAccountMeta = getAccountMetaFactory(programAddress, 'programId');
const mintMeta = toAccountMeta('mint', resolvedMint);

On this page