associatedtokenaccount

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package associatedtokenaccount provides typed instruction builders for the Associated Token Account program, the Solana program that canonicalises the mapping from (wallet, mint) pairs to a specific token account address.

The associated token account for a given wallet and mint is a program-derived address computed deterministically from [wallet, tokenProgram, mint]. Any wallet that wants to hold balances in a given mint uses its ATA for that mint, and every dapp that sends tokens to a wallet addresses the wallet's ATA without coordination.

Index

Constants

This section is empty.

Variables

View Source
var ProgramID = solana.MustPublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL")

ProgramID is the canonical address of the Associated Token Account program.

Functions

func FindAssociatedTokenAddress

func FindAssociatedTokenAddress(wallet, mint, tokenProgram solana.PublicKey) (solana.PublicKey, uint8, error)

FindAssociatedTokenAddress derives the associated token account address for (wallet, mint) under the given token program. Pass token.ProgramID for classic SPL tokens; for Token-2022 mints, pass token2022.ProgramID.

The derivation uses the standard seed order [wallet, tokenProgram, mint] with the ATA program as the program id. It returns the PDA, the bump seed, and any error from FindProgramAddress.

func NewCreate

func NewCreate(payer, wallet, mint, tokenProgram solana.PublicKey) (solana.Instruction, error)

NewCreate builds an ATA Create instruction that allocates a new associated token account for wallet + mint and funds it with rent-exempt lamports paid by payer.

Create fails if the account already exists. Use NewCreateIdempotent in retry-heavy flows where a prior attempt may have already created the account.

func NewCreateIdempotent

func NewCreateIdempotent(payer, wallet, mint, tokenProgram solana.PublicKey) (solana.Instruction, error)

NewCreateIdempotent builds the idempotent variant of Create. It succeeds without error when the ATA already exists, making it the safer choice for retry-heavy flows and the default builder for most applications.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL