Solana.SPL.AssociatedToken (Solana v0.1.0)

View Source

Functions for interacting with the Associated Token Account Program.

An associated token account's address is derived from a user's main system account and the token mint, which means each user can only have one associated token account per token.

Summary

Functions

Creates an associated token account.

Creates an associated token account idempotently, ie it doesn't do anything if account is already created.

Finds the token account address associated with a given owner and mint.

The Associated Token Account's Program ID

Functions

create_account(opts)

Creates an associated token account.

This will be owned by the owner regardless of who actually creates it.

Options

  • :payer - Required. The account which will pay for the new account's creation

  • :owner - Required. The account which will own the new account

  • :new - Required. Public key of the associated token account to create

  • :mint - Required. The mint of the new account

create_account_idempotent(opts)

Creates an associated token account idempotently, ie it doesn't do anything if account is already created.

This will be owned by the owner regardless of who actually creates it.

Options

  • :payer - Required. The account which will pay for the new account's creation

  • :owner - Required. The account which will own the new account

  • :new - Required. Public key of the associated token account to create

  • :mint - Required. The mint of the new account

find_address(mint, owner)

@spec find_address(mint :: Solana.key(), owner :: Solana.key()) ::
  {:ok, Solana.key()} | :error

Finds the token account address associated with a given owner and mint.

This address will be unique to the mint/owner combination.

id()

The Associated Token Account's Program ID