I am new to Solana dev. I am confused by the answers on StackExchange. The token mint holds information about a specific mint. An associated token account is an account linked to a user so the user can share between them the tokens. My question Is which account is account which holds data about the maximum supply of the mint, and which keeps data about who is the minting authority, the token account of that specific mint, or is an associated token account of the authoritative mint key, which distributes the tokens?
3 Answers
Following this
Before you can mint tokens (issue new supply), you need a Token Account to hold the newly issues tokens.
A Token Account holds tokens of a specific "mint" and has a specified "owner" of the account. Only the owner is authorized to decrease the Token Account balance (transfer, burn, etc.) while anyone can send tokens to the Token Account to increase its balance.
A Mint account just stores the general information about the token, including the max supply.
The token account is one that holds the tokens. But since transferring tokens between them are extra hard, because you need to send an instruction to both token accounts, the sender and receiver, they created Associated Token Account
as name says it is associated with the token account. we send the money to associated token accounts.
Mint authority is the one that initialize the account. ON client side we have createMint
import {createMint} from "@solana/spl-token"
this is its typescript signature:
createMint(connection: Connection, payer: Signer, mintAuthority: PublicKey, freezeAuthority: PublicKey | null, decimals: number, keypair?: Keypair | undefined, confirmOptions?: ConfirmOptions | undefined, programId?: PublicKey | undefined): Promise<...>
mintAuthoity
is the one that who pays for it. you could create any keypair and assign its public key as mint authority
const tokenMintAddress = await createMint(
connection,
// this is the mint authority
payer,
payer.publicKey,
payer.publicKey,
9,
payer
);
The mint
account itself holds the data about the maximum supply of the mint and the address of the mint_authority
for the mint. Only the mint_authority
can create new tokens for a mint and increase the supply.
For example here's Solana explorer links to the mint address for USDC and an NFT (max supply 1): https://explorer.solana.com/address/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v https://explorer.solana.com/address/83JwcQXVArbrG2oDRmRPeLzg58DZmm82foARd9MR3V1H
A Token Account holds tokens of a specific mint
and has a specified owner
of the Token Account. Only the owner is authorized to decrease the Token Account balance (transfer, burn, etc.) while anyone can send tokens to the Token Account to increase its balance.
An Associated Token Account is a Token Account where the address of the Token Account is derived using an owner
's public key and a token mint
. Associated Token Accounts provide a deterministic way to find the Token Account owned by a specific publicKey
for a specific token mint
.
Metaplex docs have good explanation and diagrams for the relationship between accounts: https://docs.metaplex.com/programs/token-metadata/overview
The Mint Account holds the info for maximum supply it's the supply
attribute there i guess which holds this info. The minting authority data is hold by the mint account as well
/// Mint data.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Mint {
/// Optional authority used to mint new tokens. The mint authority may
only be provided during
/// mint creation. If no mint authority is present then the mint has a
fixed supply and no
/// further tokens may be minted.
pub mint_authority: COption<Pubkey>,
/// Total supply of tokens.
pub supply: u64,
/// Number of base 10 digits to the right of the decimal place.
pub decimals: u8,
/// Is `true` if this structure has been initialized
pub is_initialized: bool,
/// Optional authority to freeze token accounts.
pub freeze_authority: COption<Pubkey>,
}
-
-
Yes then what is the purpose of the token Account? On the soldev examples, this is the definition of token account Before you can mint tokens (issue new supply), you need a Token Account to hold the newly issues tokens. Is a token account the same as an Associated token account?– Mr.HJan 26 at 15:07
-
Yes so before Associated Token Account(ATA) there used to be a token account which is a random pubkey account but ATA is a PDA and is derived from the seeds of the user address Jan 26 at 15:13
-