Functionalities
The Token Program operates through a set of instructions that allow you to create token mints, initialize token accounts, transfer tokens between accounts, and manage authorities.
It also supports multisignature accounts for enhanced security and provides mechanisms for freezing accounts and delegating token authority.
Initializing an Account
The token program has different instructions and helpers that abstract away the complexities of intializing a new account.
There are different instructions if we want to initialize a Mint
account or a Token
account, in the case of the Associated Token
account, the associated token program uses the initializeAccount
instruction under the hood after having derived the correct program derived address.
Transfer
Moves tokens from one account to another. This is the basic operation for sending tokens between users.
The owner of the token account needs to be a Signer
of that transaction, and the destination of that transfer needs to be another token account.
Approve
Grants a delegate the authority to transfer a specific amount of tokens on behalf of the account owner. This enables programmatic token transfers without giving full account control.
Revoke
Removes the current delegate's authority over the account, returning full control to the account owner.
Set Authority
Changes the authority of a mint or account. This allows transferring ownership or updating specific authority types.
Mint To
Creates new tokens and deposits them into a specified account. Only the mint authority can perform this operation.
Burn
Permanently destroys tokens by removing them from circulation. This reduces the total supply of the token.
Close Account
Closes a token account and transfers its remaining SOL rent to a destination account. The token account must have zero balance unless it's a native SOL account.
Freeze Account
Prevents all token operations on an account until it's thawed. Only the mint's freeze authority can perform this operation.
Thaw Account
Re-enables token operations on a previously frozen account. Only the mint's freeze authority can thaw accounts.