Hierarchy

  • AssociatedToken

Constructors

Properties

address: PublicKey
amount: TokenAmount
exists: boolean
info: null | Account
NATIVE_DECIMALS: 9 = 9

Methods

  • Get the address for the associated token account

    Static

    Returns

    Public key of the associated token account

    Memberof

    AssociatedToken

    Parameters

    • mint: Address

      Token mint account

    • owner: Address

      Owner of the new account

    Returns PublicKey

  • Parameters

    • connection: Connection
    • mint: Address
    • owner: Address
    • address: Address

    Returns Promise<boolean>

  • Returns true when the mint is native and the token account is actually the native wallet

    Static

    Returns

    Memberof

    AssociatedToken

    Parameters

    • owner: Address
    • mint: Address
    • tokenAccountOrNative: Address

    Returns boolean

  • TODO:

    Static

    Returns

    Memberof

    AssociatedToken

    Parameters

    • __namedParameters: {
          connection: Connection;
          decimals: number;
          mint: Address;
          owner: Address;
      }
      • connection: Connection
      • decimals: number
      • mint: Address
      • owner: Address

    Returns Promise<AssociatedToken>

  • TODO: Get mint info

    Static

    Returns

    Memberof

    AssociatedToken

    Parameters

    • connection: Connection
    • mint: Address

    Returns Promise<undefined | Mint>

  • Loads multiple token accounts, loads wrapped SOL. Batches by 100 (RPC limit)

    Parameters

    • __namedParameters: {
          connection: Connection;
          decimals: number | number[];
          mints: Address[];
          owner: Address;
      }
      • connection: Connection
      • decimals: number | number[]
      • mints: Address[]
      • owner: Address

    Returns Promise<AssociatedToken[]>

  • Loads multiple token accounts and their mints by address. Batches by 100 (RPC limit)

    Parameters

    • __namedParameters: {
          addresses: Address[];
          connection: Connection;
          decimals?: number | number[];
      }
      • addresses: Address[]
      • connection: Connection
      • Optional decimals?: number | number[]

    Returns Promise<AssociatedToken[]>

  • Loads multiple associated token accounts by owner. If the native mint is provided, loads the native SOL balance of the owner instead. If a mints array is not provided, loads all associated token accounts and the SOL balance of the owner. Batches by 100 (RPC limit)

    Parameters

    • __namedParameters: {
          connection: Connection;
          decimals?: number | number[];
          mints?: Address[];
          owner: Address;
      }
      • connection: Connection
      • Optional decimals?: number | number[]
      • Optional mints?: Address[]
      • owner: Address

    Returns Promise<AssociatedToken[]>

  • Parameters

    • __namedParameters: {
          feesBuffer: BN;
          instructions: TransactionInstruction[];
          mint: Address;
          provider: AnchorProvider;
          source: Address | TokenFormat;
      }
      • feesBuffer: BN
      • instructions: TransactionInstruction[]
      • mint: Address
      • provider: AnchorProvider
      • source: Address | TokenFormat

    Returns Promise<PublicKey>

  • Parameters

    • __namedParameters: {
          destination: Address | TokenFormat;
          instructions: TransactionInstruction[];
          mint: Address;
          provider: AnchorProvider;
      }
      • destination: Address | TokenFormat
      • instructions: TransactionInstruction[]
      • mint: Address
      • provider: AnchorProvider

    Returns Promise<PublicKey>

  • Add close associated token account IX

    Static

    Memberof

    AssociatedToken

    Parameters

    • instructions: TransactionInstruction[]
    • owner: Address
    • mint: Address
    • rentDestination: Address

    Returns void

  • If the associated token account does not exist for this mint, add instruction to create the token account.If ATA exists, do nothing.

    Static

    Returns

    returns the public key of the token account

    Memberof

    AssociatedToken

    Parameters

    • instructions: TransactionInstruction[]
    • provider: AnchorProvider
    • owner: Address
    • mint: Address

    Returns Promise<PublicKey>

  • If the token account does not exist, add instructions to create and initialize the token account. If the account exists do nothing.

    Static

    Returns

    returns the public key of the token account

    Memberof

    AssociatedToken

    Parameters

    • instructions: TransactionInstruction[]
    • provider: AnchorProvider
    • owner: Address
    • mint: Address
    • address: Address

    Returns Promise<void>

  • Create the associated token account as a pre-instruction. Unwraps sol as a post-instruction.

    Static

    Memberof

    AssociatedToken

    Parameters

    • preInstructions: TransactionInstruction[]
    • postInstructions: TransactionInstruction[]
    • provider: AnchorProvider
    • mint: Address

    Returns Promise<PublicKey>

  • Create the associated token account. Funds it if native.

    Static

    Memberof

    AssociatedToken

    Parameters

    • instructions: TransactionInstruction[]
    • provider: AnchorProvider
    • mint: Address
    • feesBuffer: BN

      How much tokens should remain unwrapped to pay for fees

    Returns Promise<PublicKey>

  • Ends the transfer by unwraps the token if it is the native mint.

    Parameters

    • __namedParameters: {
          destination: Address | TokenFormat;
          instructions: TransactionInstruction[];
          mint: Address;
          provider: AnchorProvider;
      }
      • destination: Address | TokenFormat
      • instructions: TransactionInstruction[]
      • mint: Address
      • provider: AnchorProvider

    Returns void

  • Transfer tokens from one owner to another

    Parameters

    • instructions: TransactionInstruction[]
    • mint: Address
    • sourceOwner: Address
    • destinationOwner: Address
    • amount: BN

    Returns void

  • Unwraps all SOL if the mint is native and the tokenAccount is the owner

    Parameters

    • instructions: TransactionInstruction[]
    • owner: Address
    • mint: Address

    Returns void

  • Unwraps all SOL in the associated token account.

    Parameters

    • instructions: TransactionInstruction[]
    • owner: Address

    Returns void

  • Add wrap SOL IX

    Parameters

    • instructions: TransactionInstruction[]
    • provider: AnchorProvider
    • mint: Address
    • feesBuffer: BN

      How much tokens should remain unwrapped to pay for fees

    Returns Promise<PublicKey>

  • Wraps SOL in an associated token account. The account will only be created if it doesn't exist.

    Parameters

    • instructions: TransactionInstruction[]
    • provider: AnchorProvider
    • feesBuffer: BN

      How much tokens should remain unwrapped to pay for fees

    Returns Promise<PublicKey>

Generated using TypeDoc