in-solana by Supanode

Token account not initialized

The SPL Token program expected an initialized token account but received one that has not been set up yet.

Common causes

  1. Associated Token Account not created. The user’s Associated Token Account (ATA) for a specific mint does not exist yet.
  2. Account created but not initialized. The account was allocated with createAccount but the Token program’s initializeAccount instruction was never called.
  3. Wrong account address. The address you passed is a regular wallet or a different type of account, not a token account.

How to fix

  1. Create the ATA. Use createAssociatedTokenAccountIdempotent to create the token account if it does not exist:
import { getOrCreateAssociatedTokenAccount } from "@solana/spl-token";

const ata = await getOrCreateAssociatedTokenAccount(
  connection,
  payer,
  mint,
  owner
);
  1. Use createAssociatedTokenAccountIdempotent. This instruction creates the ATA if needed and does nothing if it already exists, preventing errors from duplicate creation.
  2. Check account existence. Use getAccountInfo to verify the token account exists before calling transfer or other operations.

What is custom program error: 0x3?

Hex 0x3 is decimal 3, which maps to UninitializedAccount in the SPL Token program’s error enum. This is the same error presented differently in transaction logs.

FAQ

What is an Associated Token Account? An ATA is a deterministic token account derived from the owner’s wallet address and the token mint. Each wallet has exactly one ATA per token mint. The address is computed using getAssociatedTokenAddressSync(mint, owner).

Who pays to create the ATA? The payer specified in the createAssociatedTokenAccount instruction pays the rent-exempt minimum (~0.002 SOL for a 165-byte token account).

Can I use a non-ATA token account? Yes. You can create arbitrary token accounts, but ATAs are the standard and most wallets and programs expect them.

Error text variants

  • Token account not initialized
  • UninitializedAccount
  • Account not initialized
  • custom program error: 0x3

Updated: