InstructionAccountInputAddress

type InstructionAccountInputAddress<TInput> = TInput extends HasAddress<infer TAddress> ? TAddress : TInput extends ProgramDerivedAddress<infer TAddress> ? TAddress : TInput extends Address<infer TAddress> ? TAddress : string;

Extracts the address type parameter from an instruction account input.

Given any InstructionAccountInput or InstructionSignerInput — e.g. an Address, an address-bearing object (see HasAddress), a ProgramDerivedAddress or an account meta — this type helper resolves to the branded address string it carries. This allows generated program clients to recover the address type parameter of an account from the caller's input type alone — e.g. via InstructionAccountInputAddress<TAccountAuthority> where TAccountAuthority captures the input provided for the authority account — instead of declaring a dedicated address type parameter on the instruction builder.

When given a union of inputs, the helper distributes over it, so a union whose members all share the same address brand resolves to that brand. Inputs carrying no brand resolve to string.

Type Parameters

Type ParameterDescription
TInputThe type of the input provided by the caller for this account.

Example

type A = InstructionAccountInputAddress<Address<'1234'>>; // '1234'
type B = InstructionAccountInputAddress<TransactionSigner<'1234'>>; // '1234'
type C = InstructionAccountInputAddress<ProgramDerivedAddress<'1234'>>; // '1234'
type D = InstructionAccountInputAddress<Address>; // string

See

ResolvedInstructionAccountMeta

On this page