getResolvedInstructionAccountAsProgramDerivedAddress

function getResolvedInstructionAccountAsProgramDerivedAddress<T>(
    inputName,
    value,
): readonly [Address<T>, ProgramDerivedAddressBump];

Extracts a ProgramDerivedAddress from a resolved instruction account.

This function validates that the resolved account is a PDA and returns it. Use this when you need access to both the address and the bump seed of a PDA.

Type Parameters

Type ParameterDefault typeDescription
T extends stringstringThe address type, defaults to string.

Parameters

ParameterTypeDescription
inputNamestringThe name of the instruction input, used in error messages.
value| Address<T> | readonly [Address<T>, ProgramDerivedAddressBump] | TransactionSigner<T> | null | undefinedThe resolved account value expected to be a PDA.

Returns

readonly [Address<T>, ProgramDerivedAddressBump]

The program-derived address.

Throws

Throws a SolanaError if the value is not a ProgramDerivedAddress.

Example

const pda = getResolvedInstructionAccountAsProgramDerivedAddress('metadata', resolvedMetadata);
const [address, bump] = pda;

On this page