What is an Solana Associated Token Account on Solana?
Written by Petar Todorov
Reviewed by Brady Werkheiser
The Solana Account Model organizes and stores all on-chain data, and Associated Token Accounts (ATAs) are one of the key pieces of that model. This article will explain what an ATA is, how it works, and how to create an Associated Token Account for yourself.
What is an Associated Token Account?
An Associated Token Account is created via the Solana Associated Token Account Program, which holds information about a specific token, its balance, and its owner. It is a variant of a Program Derived Address.
Here’s what each term means:
Associated Token Account - an account that is associated with a token (think of Solana Token Program)
Program Derived Address - an address that has been “derived” (created) from a Solana Program, namely, the Associated Token Account Program
How do Associated Token Accounts and transfers between them work?
Transfers between Associated Token Accounts occur directly between the accounts, and indirectly through their wallet addresses.
Token accounts are the equivalent of an ERC-20 token on Ethereum, but with a foundational difference: Ethereum smart contracts own its state and code, and a token account on Solana contains only its code and “exports” its state (e.g. token balance) into an Associated Token Account, which is created for each owner of that token.
Let’s quickly examine USDC for an overview of what we’ve learned so far:
USDC on Solana is a token account
A token account is created by the System Program but initialized as Token mint by the SPL Token Program
Once the USDC token has been initiated, users can start making transfers
Users with USDC tokens have Associated Token Accounts that are created through the Associated Token Account Program (ATP)
The exchange of USDC between two people happens between the users’ ATAs
USDC transfers directly occur between the users’ ATAs and indirectly between their wallet addresses on Solana nodes. These transfers must be between users, whose ATAs have been created with the same token mint seed.
What is the Associated Token Account Program?
Being part of the Solana Program Library, the Associated Token Account Program is the parent program for every ATA, that maps a user’s wallet to the ATAs that he has authority over. Additionally, the ATA Program ensures that if a user wants to send a token to another user, the recipient will get it, even if he does not have an ATA for the corresponding token. The program will automatically create an ATA account in this case while the smart contract is executed on an RPC node.
The source code for the Associated Token Account Program is written in Rust and can be checked on GitHub.
Here’s how an ATA is created under the hood on TypeScript:
How does the Associated Token Account Program work?
Here's what is happening in the ATA program:
1. Get IDs for Constants
First, we get the `TOKEN_PROGRAM_ID` and `SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID` constants. A program ID is a fancier name for the program’s address.
2. Get the findAssociatedTokenAddress Function
Then, we proceed with the `findAssociatedTokenAddress` function, which returns publicKey, which will be the address of the newly created ATA.
3. Invoke the findProgramAddress Method
In the body of the function, the `findProgramAddress` method is invoked and two arguments are passed to it:
An Array of Seeds
SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID
Since ATA is a form of a Program Derived Address (PDA), the account can be created by passing arguments to the program. The creation of a PDA involves passing seeds as arguments and in this case, they are:
wallet_address - the address of the account, which will own the funds in the ATA (authority)
token_program_id - the program ID of the SPL Token Program
token_mint_address - the address of the Token account that will be stored in the ATA
The ID of the Associated Token Account Program is SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID.
How to Create an Associated Token Account
Creating an Associated Token Account is as simple as calling create-token using the spl-token-cli on Solana. Creating an ATA also assumes that the token with which it will be “associated” already exists.
The code invokes the `create-account` command, which accepts `<TOKEN_MINT_ADDRESS>` as an argument.
To create an Associated Token Account, you must follow these four steps:
Transfer SOL - the System Program initializes the ATA and makes it rent-exempt
Create Free Space - the System Program assigns free space for the ATA.
Transfer Ownership - he System Program transfers ownership of the account to the SPL Associated Token Account Program
Initialize the Account - the process summarizes the account initialization and sets the token address, the newly created ATA address, and its owner
What's the difference between owners and authorities?
Owner is the type of Solana program that controls the ATA, while authority is the account (wallet), that sends a transaction to the owner program, which then changes the data in the ATA on behalf of the authority.
What is the cost of an Associated Token Account?
By default, Associated Token Accounts must be marked as rent-exempt upon their creation, so the minimum amount that an account must hold should be at least 0.00203928 SOL. The System Program transfers this SOL to the ATA, which is deducted from the account that initiating the transaction.
Other than that initial fee, any further interaction will cost no more than an ordinary transaction on Solana.
How to Check an Associated Token Account
You can check an Associated Token Account through clients like Phantom that automatically derive all the ATAs that a user’s wallet has authority over. Additionally, since the blockchain is public, you can also access this information with the help of an explorer like Solscan.io.
Paste the address of the wallet that you’d like to check and its ATAs will be visualized under Token Accounts:
Can you link an Associated Token Account to an existing account?
Linking an Associated Token Account to an existing account is done by default behind the scenes. Due to the way an ATA is created, a program or a client can easily see the seeds of every account. They could be regarded as ‘links’ to:
the wallet that has authority over the ATA.
the address of the Token account (i.e. the token type that the ATA holds).
Build Your Solana Dapp with Alchemy
Learning about the Associated Token Account is one of the first steps to becoming a fully-fledged Solana developer. You can use our user-friendly Solana API to get a head start on building your first dApp once you've mastered Solana nodes and selected an RPC provider.
Related overviews
Learn About Compressed NFTs and How They Work
Learn What SFTs Are, How They Work, and What Makes Them Different from NFTs and SPL Tokens
Learn About the Solana Account Model, the Different Account Types, and How They All Work Together