in-solana by Supanode

Associated Token Account Program

ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL

The Associated Token Account (ATA) Program provides a deterministic way to derive token account addresses from a wallet address and token mint. Instead of creating token accounts at random addresses, ATAs use a Program Derived Address so any program or user can compute the address without an on-chain lookup.

Program ID

ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL

Address derivation

An associated token account address is a PDA derived from three seeds:

  1. The wallet (owner) address
  2. The token program ID (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA or the Token-2022 program)
  3. The token mint address
import { getAssociatedTokenAddressSync } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";

const wallet = new PublicKey("...");
const mint = new PublicKey("...");

const ata = getAssociatedTokenAddressSync(mint, wallet);

Key instructions

InstructionDescription
CreateCreates an associated token account if it does not exist. The payer funds the rent-exempt minimum
CreateIdempotentSame as Create, but succeeds silently if the account already exists
RecoverNestedRecovers tokens from a nested associated token account

Idempotent creation

CreateIdempotent is the recommended instruction for creating ATAs. Unlike Create, it does not fail if the account already exists, which avoids race conditions when multiple transactions try to create the same ATA.

FAQ

Does every wallet need an ATA for each token? Yes. A wallet needs one associated token account per token mint it holds. The ATA must be created (and funded with rent) before tokens can be received.

Who pays for ATA creation? Any account can be the payer. In practice, the sender or a relayer typically pays the ~0.00204 SOL rent-exempt minimum when the recipient’s ATA does not exist yet.

Can I use a non-ATA token account? Yes. The Token Program supports arbitrary token accounts. ATAs are a convention, not a requirement, but nearly all wallets and DeFi protocols use them.

Does the ATA Program work with Token-2022? Yes. The same program derives ATAs for both the original Token Program and Token-2022. The token program ID is included as a seed, producing different addresses for each.

Updated: