@solana/instructions
This package contains types for creating transaction instructions. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK @solana/web3.js@experimental
.
Types
IAccountMeta<TAddress>
This type represents an account's address and metadata about its mutability and whether it must be a signer of the transaction.
Typically, you will use one of its subtypes.
| isSigner | isWritable |
---|
ReadonlyAccount<TAddress> | ❌ | ❌ |
WritableAccount<TAddress> | ❌ | ✅ |
ReadonlySignerAccount<TAddress> | ✅ | ❌ |
WritableSignerAccount<TAddress> | ✅ | ✅ |
For example, you could type the rent sysvar account like this:
type RentSysvar = ReadonlyAccount<'SysvarRent111111111111111111111111111111111'>;
Instruction<TProgramAddress, TAccounts, TData>
Use this to define the structure of a transaction instruction.
type InitializeStakeInstruction = Instruction<
'StakeConfig11111111111111111111111111111111',
[
WritableAccount,
RentSysvar
],
InitializeStakeInstructionData
>;
Instructions that do not require data may omit the TData
type parameter.