On Solana, a token is not a contract you deploy. You create a mint account owned by the shared SPL Token program, which records the token's supply, decimals and mint authority. Balances live in separate token accounts, one per wallet per mint, and the associated token account (ATA) is the standard one: an address derived deterministically from the wallet, the token program and the mint, so anyone can compute where a wallet's balance for that token lives. To create a token you run spl-token create-token, then create an ATA and mint into it; to transfer, you move tokens from your ATA to the recipient's ATA, creating it first if it doesn't exist.
How SPL tokens are structured
On Ethereum, every ERC-20 is its own contract with its own balance mapping. Solana does the opposite: one program implements every token, and state is split across accounts. If the account model is new to you, how Bitcoin and Ethereum track balances is useful background.
| Account | Size | Owned by | Holds |
|---|---|---|---|
| Mint | 82 bytes | Token program | Supply, decimals, mint authority, freeze authority |
| Token account | 165 bytes | Token program | Mint, owner (a wallet or PDA), amount, delegate, state, close authority |
| Wallet | 0 bytes of data | System program | SOL only |
Two different "owners" appear here, and mixing them up causes most beginner confusion. The account owner of a token account is always the token program, because only that program can change its data. The token owner field inside the account is your wallet, which is the key allowed to sign transfers from it.
There are two token programs. The original Token program (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA) is what most tokens use. Token-2022 (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb) is a superset that adds optional extensions such as on-mint metadata and transfer fees. The commands below use the original program; Token-2022 works the same way with --program-id and is worth a separate look before you pick it.
What is an associated token account?
A wallet could hold many token accounts for the same mint at random addresses, which would make it impossible to know where to send tokens. The Associated Token Account program (ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL) fixes this by defining one canonical address per wallet and mint. It is a program-derived address (PDA) found from these seeds:
seeds = [wallet_address, token_program_id, mint_address]
program = ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL
Because the derivation is deterministic, a sender can compute the recipient's ATA without asking them. Anyone may create it (the creator pays the rent), but the wallet in the seeds is always set as the token owner, so creating someone else's ATA can't give you control of it.
Every account must hold enough SOL to be rent-exempt. For a 165-byte token account that is about 0.00204 SOL, and for an 82-byte mint about 0.00146 SOL. Whoever creates the ATA pays that deposit, and the owner can reclaim it later by closing an empty account. If a transaction fails because the payer can't cover it, see why Solana says "insufficient funds for rent".
How do I create a token with the CLI?
Install the Solana CLI and spl-token-cli, point them at devnet, and fund a keypair:
solana config set --url devnet
solana-keygen new --outfile ~/.config/solana/id.json # skip if you already have one
solana airdrop 2
# 1. Create the mint (default is 9 decimals; 6 is common for stablecoin-like tokens)
spl-token create-token --decimals 6
# Address: 7xKX...Mint
# 2. Create your associated token account for that mint
spl-token create-account 7xKX...Mint
# 3. Mint 1,000 tokens into it (the CLI converts using the mint's decimals)
spl-token mint 7xKX...Mint 1000
spl-token balance 7xKX...Mint
spl-token supply 7xKX...Mint
create-token makes your keypair the mint authority, so you can mint more at any time. If the supply is meant to be fixed, remove that power once minting is done. The same applies to the optional freeze authority, which can freeze any holder's token account:
spl-token authorize 7xKX...Mint mint --disable
spl-token display 7xKX...Mint # confirm "Mint authority: (not set)"
Disabling is irreversible. Holders and explorers check these two fields, so leaving them set on a token that claims a fixed supply is a red flag.
How do I transfer SPL tokens?
Pass the recipient's wallet address. The CLI derives their ATA and, with --fund-recipient, creates it at your expense if it doesn't exist yet:
spl-token transfer 7xKX...Mint 25 RecipientWa11etAddress... --fund-recipient
If the recipient wallet has never held SOL, the CLI stops with an error as a guard against typos; add --allow-unfunded-recipient once you've checked the address. You can always confirm where tokens will land with:
spl-token address --token 7xKX...Mint --owner RecipientWa11etAddress... --verbose
Doing the same in TypeScript
With @solana/web3.js and @solana/spl-token, the full flow is a handful of calls. Amounts are integers in base units, so 25 tokens with 6 decimals is 25_000_000n:
import { readFileSync } from "node:fs";
import { Connection, Keypair, PublicKey, clusterApiUrl } from "@solana/web3.js";
import {
createMint,
getOrCreateAssociatedTokenAccount,
mintTo,
transferChecked,
} from "@solana/spl-token";
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
const payer = Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(readFileSync(process.env.KEYPAIR_PATH!, "utf8")))
);
const recipient = new PublicKey("RecipientWa11etAddress...");
const DECIMALS = 6;
// Mint with payer as mint authority and no freeze authority
const mint = await createMint(connection, payer, payer.publicKey, null, DECIMALS);
// Source and destination ATAs (created if missing, payer pays rent)
const from = await getOrCreateAssociatedTokenAccount(connection, payer, mint, payer.publicKey);
const to = await getOrCreateAssociatedTokenAccount(connection, payer, mint, recipient);
await mintTo(connection, payer, mint, from.address, payer, 1_000n * 10n ** BigInt(DECIMALS));
const sig = await transferChecked(
connection,
payer, // fee payer
from.address, // source token account
mint,
to.address, // destination token account, not the wallet
payer, // token owner of the source
25n * 10n ** BigInt(DECIMALS),
DECIMALS
);
console.log("transfer:", sig);
transferChecked passes the mint and decimals so the program can reject a mismatch, which protects against sending a wrong-decimals amount. Prefer it over plain transfer.
To compute an ATA without creating it, use getAssociatedTokenAddressSync(mint, owner). For production apps, build the transaction yourself with createAssociatedTokenAccountIdempotentInstruction followed by the transfer instruction: the idempotent version succeeds whether or not the ATA already exists, so a race with another sender can't fail your transaction. The newer @solana/kit SDK exposes the same instructions through @solana-program/token, including findAssociatedTokenPda.
Common mistakes and how to avoid them
Sending to the wrong kind of address. Wallet addresses are on the ed25519 curve; ATAs are PDAs and are not. getAssociatedTokenAddressSync throws TokenOwnerOffCurveError if you pass an ATA (or any PDA) as the owner, which catches the classic mistake of deriving "the ATA of an ATA". If the owner really is a PDA, such as a program's vault, pass allowOwnerOffCurve = true deliberately.
Mixing token programs. An ATA derived with the Token program ID is a different address from one derived with Token-2022. If a mint belongs to Token-2022, every helper call needs that programId, or you get IncorrectProgramId or an "account not found" style error.
Forgetting decimals. On-chain amounts are u64 base units. Display code must divide by 10^decimals, and input code must multiply. Read decimals from the mint rather than hard-coding them.
Underpricing busy-network transactions. Creating an ATA and transferring in one transaction uses more compute than a SOL transfer. When the network is congested, setting priority fees and compute unit limits and handling expired blockhashes and dropped transactions make the difference between a transfer that lands and one that silently disappears.
Leaving authorities open by accident. Check mint and freeze authorities with spl-token display before launch, and keep any authority you retain behind a multisig or hardware-backed key.
Token approvals. SPL token accounts support a single delegate with an allowance, set with approve. It is less commonly abused than ERC-20 allowances, but the same advice applies: approve exact amounts and revoke when done.
Name and symbol aren't in the mint. A classic SPL mint has no name, symbol or logo. Wallets read them from a Metaplex Token Metadata account or, on Token-2022, the metadata extension. Without one, your token shows as "Unknown".
Checklist
- A token is a mint account under the SPL Token program; balances live in token accounts.
- The ATA is the PDA of
[wallet, token_program, mint]under the Associated Token Account program, so senders can derive it. - Create with
spl-token create-token,create-account,mint; transfer withspl-token transfer ... --fund-recipient. - In code, use
getOrCreateAssociatedTokenAccountor the idempotent create instruction, thentransferChecked. - Amounts are integers in base units; always apply the mint's decimals.
- Use the same token program ID everywhere for a given mint.
- Disable or secure the mint and freeze authorities before anyone relies on the supply.
- Add metadata so wallets can display the token, and budget about 0.002 SOL of rent per new token account.
Get the weekly commit
New blockchain deep dives every week.