Options
All
  • Public
  • Public/Protected
  • All
Menu

@project-serum/anchor - v0.17.0

Index

Type aliases

Accounts

Accounts: {}

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 declaration

Address

Address: PublicKey | string

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

Context

Context<A>: { accounts?: A; instructions?: TransactionInstruction[]; options?: ConfirmOptions; 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[]

    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 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

Event<T>: { data: T; name: string }

Type parameters

  • T = Record<string, unknown>

Type declaration

  • data: T
  • name: string

Idl

Idl: { accounts?: IdlTypeDef[]; errors?: IdlErrorCode[]; events?: IdlEvent[]; instructions: IdlInstruction[]; name: string; state?: IdlState; types?: IdlTypeDef[]; version: string }

Type declaration

  • Optional accounts?: IdlTypeDef[]
  • Optional errors?: IdlErrorCode[]
  • Optional events?: IdlEvent[]
  • instructions: IdlInstruction[]
  • name: string
  • Optional state?: IdlState
  • Optional types?: IdlTypeDef[]
  • version: string

Instruction

Instruction: { data: Object; name: string }

Type declaration

  • data: Object
  • name: string

InstructionFn

InstructionFn: IxProps & (...args: any[]) => any

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.

RpcFn

RpcFn: (...args: any[]) => Promise<TransactionSignature>

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

Type declaration

SimulateFn

SimulateFn: (...args: any[]) => Promise<SimulateResponse>

RpcFn 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 declaration

    • (...args: any[]): Promise<SimulateResponse>
    • Parameters

      • Rest ...args: any[]

      Returns Promise<SimulateResponse>

Subscription

Subscription: { ee: EventEmitter; listener: number }

Type declaration

  • ee: EventEmitter
  • listener: number

TransactionFn

TransactionFn: (...args: any[]) => Transaction

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

Type declaration

Variables

Const workspace

workspace: any = ...

The workspace namespace provides a convenience API to automatically search for and deserialize Program objects defined by compiled IDLs in an Anchor workspace.

This API is for Node only.

Functions

getProvider

parseIdlErrors

  • parseIdlErrors(idl: Idl): Map<number, string>

setProvider

splitArgsAndCtx

  • splitArgsAndCtx(idlIx: IdlInstruction, args: any[]): [any[], Context]

toInstruction

  • toInstruction(idlIx: IdlInstruction | IdlStateMethod, ...args: any[]): {}
  • Parameters

    • idlIx: IdlInstruction | IdlStateMethod
    • Rest ...args: any[]

    Returns {}

    • [key: string]: any

translateAddress

validateAccounts

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

Generated using TypeDoc