Options
All
  • Public
  • Public/Protected
  • All
Menu

@project-serum/anchor - v0.25.0

Index

Type aliases

AccountNamespace<IDL>: { [ M in keyof AllAccountsMap<IDL>]: AccountClient<IDL> }

The namespace provides handles to an AccountClient object for each account in a program.

Usage

account.<account-client>

Example

To fetch a Counter account from the above example,

const counter = await program.account.counter.fetch(address);

For the full API, see the AccountClient reference.

Type parameters

Accounts<A>: { [ N in A["name"]]: Account<A & { name: N }> }

A set of accounts mapping one-to-one to the program's accounts struct, i.e., the type deriving #[derive(Accounts)].

The name of each field should match the name for that account in the IDL.

If multiple accounts are nested in the rust program, then they should be nested here.

Type parameters

  • A: IdlAccountItem = IdlAccountItem

Address: PublicKey | string

An address to identify an account on chain. Can be a PublicKey, or Base 58 encoded string.

Context<A>: { accounts?: A; instructions?: TransactionInstruction[]; options?: ConfirmOptions; postInstructions?: TransactionInstruction[]; preInstructions?: TransactionInstruction[]; remainingAccounts?: AccountMeta[]; signers?: Signer[] }

Context provides all non-argument inputs for generating Anchor transactions.

Type parameters

Type declaration

  • Optional accounts?: A

    Accounts used in the instruction context.

  • Optional instructions?: TransactionInstruction[]
    deprecated

    use preInstructions instead. Instructions to run before a given method. Often this is used, for example to create accounts prior to executing a method.

  • Optional options?: ConfirmOptions

    Commitment parameters to use for a transaction.

  • Optional postInstructions?: TransactionInstruction[]

    Instructions to run after a given method. Often this is used, for example to close accounts after executing a method.

  • Optional preInstructions?: TransactionInstruction[]

    Instructions to run before a given method. Often this is used, for example to create accounts prior to executing a method.

  • Optional remainingAccounts?: AccountMeta[]

    All accounts to pass into an instruction after the main accounts. This can be used for optional or otherwise unknown accounts.

  • Optional signers?: Signer[]

    Accounts that must sign a given transaction.

Event<E, Defined>: { data: EventData<E["fields"][number], Defined>; name: E["name"] }

Type parameters

  • E: IdlEvent = IdlEvent

  • Defined = Record<string, never>

Type declaration

  • data: EventData<E["fields"][number], Defined>
  • name: E["name"]
EventData<T, Defined>: { [ N in T["name"]]: DecodeType<T & { name: N }["type"], Defined> }

Type parameters

  • T: IdlEventField

  • Defined

Idl: { accounts?: IdlAccountDef[]; constants?: IdlConstant[]; docs?: string[]; errors?: IdlErrorCode[]; events?: IdlEvent[]; instructions: IdlInstruction[]; metadata?: IdlMetadata; name: string; state?: IdlState; types?: IdlTypeDef[]; version: string }

Type declaration

  • Optional accounts?: IdlAccountDef[]
  • Optional constants?: IdlConstant[]
  • Optional docs?: string[]
  • Optional errors?: IdlErrorCode[]
  • Optional events?: IdlEvent[]
  • instructions: IdlInstruction[]
  • Optional metadata?: IdlMetadata
  • name: string
  • Optional state?: IdlState
  • Optional types?: IdlTypeDef[]
  • version: string
IdlAccounts<T>: TypeDefDictionary<NonNullable<T["accounts"]>, Record<string, never>>

Type parameters

IdlTypes<T>: TypeDefDictionary<NonNullable<T["types"]>, Record<string, never>>

Type parameters

Instruction: { data: Object; name: string }

Type declaration

  • data: Object
  • name: string
InstructionFn<IDL, I>: InstructionContextFn<IDL, I, TransactionInstruction> & IxProps<Accounts<I["accounts"][number]>>

Function to create a TransactionInstruction generated from an IDL. Additionally it provides an accounts utility method, returning a list of ordered accounts for the instruction.

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

InstructionNamespace<IDL, I>: MakeInstructionsNamespace<IDL, I, TransactionInstruction, { [ M in keyof AllInstructionsMap<IDL>]: { accounts: any } }>

The namespace provides functions to build TransactionInstruction objects for each method of a program.

Usage

instruction.<method>(...args, ctx);

Parameters

  1. args - The positional arguments for the program. The type and number of these arguments depend on the program being used.
  2. ctx - Context non-argument parameters to pass to the method. Always the last parameter in the method call.

Example

To create an instruction for the increment method above,

const tx = await program.instruction.increment({
accounts: {
counter,
},
});

Type parameters

  • IDL: Idl = Idl

  • I: IdlInstruction = IDL["instructions"][number]

MethodsNamespace<IDL, I>: MakeMethodsNamespace<IDL, I>

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

RpcFn<IDL, I>: InstructionContextFn<IDL, I, Promise<TransactionSignature>>

RpcFn is a single RPC method generated from an IDL, sending a transaction paid for and signed by the configured provider.

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

RpcNamespace<IDL, I>: MakeInstructionsNamespace<IDL, I, Promise<TransactionSignature>>

The namespace provides async methods to send signed transactions for each non-state method on Anchor program.

Keys are method names, values are RPC functions returning a TransactionInstruction.

Usage

rpc.<method>(...args, ctx);

Parameters

  1. args - The positional arguments for the program. The type and number of these arguments depend on the program being used.
  2. ctx - Context non-argument parameters to pass to the method. Always the last parameter in the method call. ```

Example

To send a transaction invoking the increment method above,

const txSignature = await program.rpc.increment({
accounts: {
counter,
authority,
},
});

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

SimulateFn<IDL, I>: InstructionContextFn<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>

SimulateFn is a single method generated from an IDL. It simulates a method against a cluster configured by the provider, returning a list of all the events and raw logs that were emitted during the execution of the method.

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

SimulateNamespace<IDL, I>: MakeInstructionsNamespace<IDL, I, Promise<SimulateResponse<NullableEvents<IDL>, IdlTypes<IDL>>>>

The namespace provides functions to simulate transactions for each method of a program, returning a list of deserialized events and raw program logs.

One can use this to read data calculated from a program on chain, by emitting an event in the program and reading the emitted event client side via the simulate namespace.

Usage

program.simulate.<method>(...args, ctx);

Parameters

  1. args - The positional arguments for the program. The type and number of these arguments depend on the program being used.
  2. ctx - Context non-argument parameters to pass to the method. Always the last parameter in the method call.

Example

To simulate the increment method above,

const events = await program.simulate.increment({
accounts: {
counter,
},
});

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

SplToken: { accounts: [{ name: "mint"; type: { fields: [{ name: "mintAuthority"; type: { coption: "publicKey" } }, { name: "supply"; type: "u64" }, { name: "decimals"; type: "u8" }, { name: "isInitialized"; type: "bool" }, { name: "freezeAuthority"; type: { coption: "publicKey" } }]; kind: "struct" } }, { name: "token"; type: { fields: [{ name: "mint"; type: "publicKey" }, { name: "authority"; type: "publicKey" }, { name: "amount"; type: "u64" }, { name: "delegate"; type: { coption: "publicKey" } }, { name: "state"; type: "u8" }, { name: "isNative"; type: { coption: "u64" } }, { name: "delegatedAmount"; type: "u64" }, { name: "closeAuthority"; type: { coption: "publicKey" } }]; kind: "struct" } }]; instructions: [{ accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "decimals"; type: "u8" }, { name: "mintAuthority"; type: "publicKey" }, { name: "freezeAuthority"; type: { coption: "publicKey" } }]; name: "initializeMint" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "authority" }, { isMut: false; isSigner: false; name: "rent" }]; args: []; name: "initializeAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "m"; type: "u8" }]; name: "initializeMultisig" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: true; isSigner: false; name: "destination" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "transfer" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: false; name: "delegate" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "approve" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: true; name: "authority" }]; args: []; name: "revoke" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "authorityType"; type: "u8" }, { name: "newAuthority"; type: { coption: "publicKey" } }]; name: "setAuthority" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "mintTo" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "burn" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: true; isSigner: false; name: "destination" }, { isMut: false; isSigner: false; name: "authority" }]; args: []; name: "closeAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: []; name: "freezeAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: []; name: "thawAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: true; isSigner: false; name: "destination" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "transferChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "delegate" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "approveChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "mintToChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "burnChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "authority"; type: "publicKey" }]; name: "initializeAccount2" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }]; args: []; name: "syncNative" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }]; args: [{ name: "authority"; type: "publicKey" }]; name: "initializeAccount3" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }]; args: [{ name: "m"; type: "u8" }]; name: "initializeMultisig2" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }]; args: [{ name: "decimals"; type: "u8" }, { name: "mintAuthority"; type: "publicKey" }, { name: "freezeAuthority"; type: { coption: "publicKey" } }]; name: "initializeMint2" }]; name: "spl_token"; version: "0.1.0" }

SplToken IDL.

Type declaration

  • accounts: [{ name: "mint"; type: { fields: [{ name: "mintAuthority"; type: { coption: "publicKey" } }, { name: "supply"; type: "u64" }, { name: "decimals"; type: "u8" }, { name: "isInitialized"; type: "bool" }, { name: "freezeAuthority"; type: { coption: "publicKey" } }]; kind: "struct" } }, { name: "token"; type: { fields: [{ name: "mint"; type: "publicKey" }, { name: "authority"; type: "publicKey" }, { name: "amount"; type: "u64" }, { name: "delegate"; type: { coption: "publicKey" } }, { name: "state"; type: "u8" }, { name: "isNative"; type: { coption: "u64" } }, { name: "delegatedAmount"; type: "u64" }, { name: "closeAuthority"; type: { coption: "publicKey" } }]; kind: "struct" } }]
  • instructions: [{ accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "decimals"; type: "u8" }, { name: "mintAuthority"; type: "publicKey" }, { name: "freezeAuthority"; type: { coption: "publicKey" } }]; name: "initializeMint" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "authority" }, { isMut: false; isSigner: false; name: "rent" }]; args: []; name: "initializeAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "m"; type: "u8" }]; name: "initializeMultisig" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: true; isSigner: false; name: "destination" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "transfer" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: false; name: "delegate" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "approve" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: true; name: "authority" }]; args: []; name: "revoke" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "authorityType"; type: "u8" }, { name: "newAuthority"; type: { coption: "publicKey" } }]; name: "setAuthority" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "mintTo" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }]; name: "burn" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: true; isSigner: false; name: "destination" }, { isMut: false; isSigner: false; name: "authority" }]; args: []; name: "closeAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: []; name: "freezeAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: []; name: "thawAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: true; isSigner: false; name: "destination" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "transferChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "delegate" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "approveChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "mintToChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "source" }, { isMut: true; isSigner: false; name: "mint" }, { isMut: false; isSigner: true; name: "authority" }]; args: [{ name: "amount"; type: "u64" }, { name: "decimals"; type: "u8" }]; name: "burnChecked" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "authority"; type: "publicKey" }]; name: "initializeAccount2" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }]; args: []; name: "syncNative" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: false; name: "mint" }]; args: [{ name: "authority"; type: "publicKey" }]; name: "initializeAccount3" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }]; args: [{ name: "m"; type: "u8" }]; name: "initializeMultisig2" }, { accounts: [{ isMut: true; isSigner: false; name: "mint" }]; args: [{ name: "decimals"; type: "u8" }, { name: "mintAuthority"; type: "publicKey" }, { name: "freezeAuthority"; type: { coption: "publicKey" } }]; name: "initializeMint2" }]
  • name: "spl_token"
  • version: "0.1.0"
Subscription: { ee: EventEmitter; listener: number }

Type declaration

  • ee: EventEmitter
  • listener: number
SystemProgram: { accounts: [{ name: "nonce"; type: { fields: [{ name: "version"; type: "u32" }, { name: "state"; type: "u32" }, { name: "authorizedPubkey"; type: "publicKey" }, { name: "nonce"; type: "publicKey" }, { name: "feeCalculator"; type: { defined: "FeeCalculator" } }]; kind: "struct" } }]; instructions: [{ accounts: [{ isMut: true; isSigner: true; name: "from" }, { isMut: true; isSigner: true; name: "to" }]; args: [{ name: "lamports"; type: "u64" }, { name: "space"; type: "u64" }, { name: "owner"; type: "publicKey" }]; name: "createAccount" }, { accounts: [{ isMut: true; isSigner: true; name: "pubkey" }]; args: [{ name: "owner"; type: "publicKey" }]; name: "assign" }, { accounts: [{ isMut: true; isSigner: true; name: "from" }, { isMut: true; isSigner: false; name: "to" }]; args: [{ name: "lamports"; type: "u64" }]; name: "transfer" }, { accounts: [{ isMut: true; isSigner: true; name: "from" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: true; name: "base" }]; args: [{ name: "base"; type: "publicKey" }, { name: "seed"; type: "string" }, { name: "lamports"; type: "u64" }, { name: "space"; type: "u64" }, { name: "owner"; type: "publicKey" }]; name: "createAccountWithSeed" }, { accounts: [{ isMut: true; isSigner: false; name: "nonce" }, { isMut: false; isSigner: false; name: "recentBlockhashes" }, { isMut: false; isSigner: true; name: "authorized" }]; args: [{ name: "authorized"; type: "publicKey" }]; name: "advanceNonceAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "nonce" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: false; name: "recentBlockhashes" }, { isMut: false; isSigner: false; name: "rent" }, { isMut: false; isSigner: true; name: "authorized" }]; args: [{ name: "lamports"; type: "u64" }]; name: "withdrawNonceAccount" }, { accounts: [{ isMut: true; isSigner: true; name: "nonce" }, { isMut: false; isSigner: false; name: "recentBlockhashes" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "authorized"; type: "publicKey" }]; name: "initializeNonceAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "nonce" }, { isMut: false; isSigner: true; name: "authorized" }]; args: [{ name: "authorized"; type: "publicKey" }]; name: "authorizeNonceAccount" }, { accounts: [{ isMut: true; isSigner: true; name: "pubkey" }]; args: [{ name: "space"; type: "u64" }]; name: "allocate" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: true; name: "base" }]; args: [{ name: "base"; type: "publicKey" }, { name: "seed"; type: "string" }, { name: "space"; type: "u64" }, { name: "owner"; type: "publicKey" }]; name: "allocateWithSeed" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: true; name: "base" }]; args: [{ name: "base"; type: "publicKey" }, { name: "seed"; type: "string" }, { name: "owner"; type: "publicKey" }]; name: "assignWithSeed" }, { accounts: [{ isMut: true; isSigner: false; name: "from" }, { isMut: false; isSigner: true; name: "base" }, { isMut: true; isSigner: false; name: "to" }]; args: [{ name: "lamports"; type: "u64" }, { name: "seed"; type: "string" }, { name: "owner"; type: "publicKey" }]; name: "transferWithSeed" }]; name: "system_program"; types: [{ name: "FeeCalculator"; type: { fields: [{ name: "lamportsPerSignature"; type: "u64" }]; kind: "struct" } }]; version: "0.1.0" }

System IDL.

Type declaration

  • accounts: [{ name: "nonce"; type: { fields: [{ name: "version"; type: "u32" }, { name: "state"; type: "u32" }, { name: "authorizedPubkey"; type: "publicKey" }, { name: "nonce"; type: "publicKey" }, { name: "feeCalculator"; type: { defined: "FeeCalculator" } }]; kind: "struct" } }]
  • instructions: [{ accounts: [{ isMut: true; isSigner: true; name: "from" }, { isMut: true; isSigner: true; name: "to" }]; args: [{ name: "lamports"; type: "u64" }, { name: "space"; type: "u64" }, { name: "owner"; type: "publicKey" }]; name: "createAccount" }, { accounts: [{ isMut: true; isSigner: true; name: "pubkey" }]; args: [{ name: "owner"; type: "publicKey" }]; name: "assign" }, { accounts: [{ isMut: true; isSigner: true; name: "from" }, { isMut: true; isSigner: false; name: "to" }]; args: [{ name: "lamports"; type: "u64" }]; name: "transfer" }, { accounts: [{ isMut: true; isSigner: true; name: "from" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: true; name: "base" }]; args: [{ name: "base"; type: "publicKey" }, { name: "seed"; type: "string" }, { name: "lamports"; type: "u64" }, { name: "space"; type: "u64" }, { name: "owner"; type: "publicKey" }]; name: "createAccountWithSeed" }, { accounts: [{ isMut: true; isSigner: false; name: "nonce" }, { isMut: false; isSigner: false; name: "recentBlockhashes" }, { isMut: false; isSigner: true; name: "authorized" }]; args: [{ name: "authorized"; type: "publicKey" }]; name: "advanceNonceAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "nonce" }, { isMut: true; isSigner: false; name: "to" }, { isMut: false; isSigner: false; name: "recentBlockhashes" }, { isMut: false; isSigner: false; name: "rent" }, { isMut: false; isSigner: true; name: "authorized" }]; args: [{ name: "lamports"; type: "u64" }]; name: "withdrawNonceAccount" }, { accounts: [{ isMut: true; isSigner: true; name: "nonce" }, { isMut: false; isSigner: false; name: "recentBlockhashes" }, { isMut: false; isSigner: false; name: "rent" }]; args: [{ name: "authorized"; type: "publicKey" }]; name: "initializeNonceAccount" }, { accounts: [{ isMut: true; isSigner: false; name: "nonce" }, { isMut: false; isSigner: true; name: "authorized" }]; args: [{ name: "authorized"; type: "publicKey" }]; name: "authorizeNonceAccount" }, { accounts: [{ isMut: true; isSigner: true; name: "pubkey" }]; args: [{ name: "space"; type: "u64" }]; name: "allocate" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: true; name: "base" }]; args: [{ name: "base"; type: "publicKey" }, { name: "seed"; type: "string" }, { name: "space"; type: "u64" }, { name: "owner"; type: "publicKey" }]; name: "allocateWithSeed" }, { accounts: [{ isMut: true; isSigner: false; name: "account" }, { isMut: false; isSigner: true; name: "base" }]; args: [{ name: "base"; type: "publicKey" }, { name: "seed"; type: "string" }, { name: "owner"; type: "publicKey" }]; name: "assignWithSeed" }, { accounts: [{ isMut: true; isSigner: false; name: "from" }, { isMut: false; isSigner: true; name: "base" }, { isMut: true; isSigner: false; name: "to" }]; args: [{ name: "lamports"; type: "u64" }, { name: "seed"; type: "string" }, { name: "owner"; type: "publicKey" }]; name: "transferWithSeed" }]
  • name: "system_program"
  • types: [{ name: "FeeCalculator"; type: { fields: [{ name: "lamportsPerSignature"; type: "u64" }]; kind: "struct" } }]
  • version: "0.1.0"
TransactionFn<IDL, I>: InstructionContextFn<IDL, I, Transaction>

Tx is a function to create a Transaction for a given program instruction.

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

TransactionNamespace<IDL, I>: MakeInstructionsNamespace<IDL, I, Transaction>

The namespace provides functions to build Transaction objects for each method of a program.

Usage

program.transaction.<method>(...args, ctx);

Parameters

  1. args - The positional arguments for the program. The type and number of these arguments depend on the program being used.
  2. ctx - Context non-argument parameters to pass to the method. Always the last parameter in the method call.

Example

To create an instruction for the increment method above,

const tx = await program.transaction.increment({
accounts: {
counter,
},
});

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

ViewFn<IDL, I>: InstructionContextFn<IDL, I, Promise<any>>

ViewFn is a single method generated from an IDL. It simulates a method against a cluster configured by the provider, and then parses the events and extracts return data from the raw logs emitted during the simulation.

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

ViewNamespace<IDL, I>: MakeInstructionsNamespace<IDL, I, Promise<any>>

Type parameters

  • IDL: Idl = Idl

  • I: AllInstructions<IDL> = AllInstructions<IDL>

Variables

ACCOUNT_DISCRIMINATOR_SIZE: 8 = 8

Number of bytes of the account discriminator.

LangErrorCode: { AccountDidNotDeserialize: number; AccountDidNotSerialize: number; AccountDiscriminatorAlreadySet: number; AccountDiscriminatorMismatch: number; AccountDiscriminatorNotFound: number; AccountDuplicateReallocs: number; AccountNotAssociatedTokenAccount: number; AccountNotEnoughKeys: number; AccountNotInitialized: number; AccountNotMutable: number; AccountNotProgramData: number; AccountNotSigner: number; AccountNotSystemOwned: number; AccountOwnedByWrongProgram: number; AccountReallocExceedsLimit: number; AccountSysvarMismatch: number; ConstraintAddress: number; ConstraintAssociated: number; ConstraintAssociatedInit: number; ConstraintClose: number; ConstraintExecutable: number; ConstraintHasOne: number; ConstraintMintDecimals: number; ConstraintMintFreezeAuthority: number; ConstraintMintMintAuthority: number; ConstraintMut: number; ConstraintOwner: number; ConstraintRaw: number; ConstraintRentExempt: number; ConstraintSeeds: number; ConstraintSigner: number; ConstraintSpace: number; ConstraintState: number; ConstraintTokenMint: number; ConstraintTokenOwner: number; ConstraintZero: number; DeclaredProgramIdMismatch: number; Deprecated: number; IdlInstructionInvalidProgram: number; IdlInstructionStub: number; InstructionDidNotDeserialize: number; InstructionDidNotSerialize: number; InstructionFallbackNotFound: number; InstructionMissing: number; InvalidProgramExecutable: number; InvalidProgramId: number; RequireEqViolated: number; RequireGtViolated: number; RequireGteViolated: number; RequireKeysEqViolated: number; RequireKeysNeqViolated: number; RequireNeqViolated: number; RequireViolated: number; StateInvalidAddress: number } = ...

Type declaration

  • AccountDidNotDeserialize: number
  • AccountDidNotSerialize: number
  • AccountDiscriminatorAlreadySet: number
  • AccountDiscriminatorMismatch: number
  • AccountDiscriminatorNotFound: number
  • AccountDuplicateReallocs: number
  • AccountNotAssociatedTokenAccount: number
  • AccountNotEnoughKeys: number
  • AccountNotInitialized: number
  • AccountNotMutable: number
  • AccountNotProgramData: number
  • AccountNotSigner: number
  • AccountNotSystemOwned: number
  • AccountOwnedByWrongProgram: number
  • AccountReallocExceedsLimit: number
  • AccountSysvarMismatch: number
  • ConstraintAddress: number
  • ConstraintAssociated: number
  • ConstraintAssociatedInit: number
  • ConstraintClose: number
  • ConstraintExecutable: number
  • ConstraintHasOne: number
  • ConstraintMintDecimals: number
  • ConstraintMintFreezeAuthority: number
  • ConstraintMintMintAuthority: number
  • ConstraintMut: number
  • ConstraintOwner: number
  • ConstraintRaw: number
  • ConstraintRentExempt: number
  • ConstraintSeeds: number
  • ConstraintSigner: number
  • ConstraintSpace: number
  • ConstraintState: number
  • ConstraintTokenMint: number
  • ConstraintTokenOwner: number
  • ConstraintZero: number
  • DeclaredProgramIdMismatch: number
  • Deprecated: number
  • IdlInstructionInvalidProgram: number
  • IdlInstructionStub: number
  • InstructionDidNotDeserialize: number
  • InstructionDidNotSerialize: number
  • InstructionFallbackNotFound: number
  • InstructionMissing: number
  • InvalidProgramExecutable: number
  • InvalidProgramId: number
  • RequireEqViolated: number
  • RequireGtViolated: number
  • RequireGteViolated: number
  • RequireKeysEqViolated: number
  • RequireKeysNeqViolated: number
  • RequireNeqViolated: number
  • RequireViolated: number
  • StateInvalidAddress: number
LangErrorMessage: Map<number, string> = ...
workspace: any

Functions

  • eventDiscriminator(name: string): Buffer
  • parseIdlErrors(idl: Idl): Map<number, string>
  • splitArgsAndCtx(idlIx: IdlInstruction, args: any[]): [any[], Context]
  • stateDiscriminator(name: string): Promise<Buffer>
  • toInstruction(idlIx: IdlInstruction, ...args: any[]): {}
  • translateError(err: any, idlErrors: Map<number, string>): any
  • Parameters

    • err: any
    • idlErrors: Map<number, string>

    Returns any

  • validateAccounts(ixAccounts: IdlAccountItem[], accounts?: Accounts<IdlAccountItem>): void

Generated using TypeDoc