Solana SPL and Tokens
handling fungible and non fungible tokens.
- solana
- blockchain
- crypto
Continuing the comparison between Solana and Ethereum, we naturally arrive at how fungible tokens are handled. Solana provides the Solana Program Library - a collection of programs designed for specific use cases. It contains the Solana Token Program (STP). This enables us to mint, burn and transfer tokens.
When creating a new token, a user calls the STP with the instruction create-token, with the specification of the public key that is part of the key pair that is allowed to mint tokens - this is the mint authority. A mint account is created by the STP. Thus, the account owner is the STP. An SPL token can only have one mint account associated with it. Note - the mint account does not hold the balance - i.e. the number of existing tokens.
So, each mint account specifies the following:
- account address
- num of tokens minted
- mint authority
- num of decimals for smallest denomination
Now we send another instruction, this time to the STP to create a new storage account - a token account. This is a data storage account which holds the balance - the number of existing tokens. The token account is associated with a mint account and is owned by the STP.
Finally, for a person to receive and hold an SPL token, they must have an Associated Token Account (ATA). Each such account is associated with one type of token and one key pair.
The Associated Token Account Program (ATAP) is the program which handles transfers between ATA's. Instructions are signed and sent to the ATAP in order to move tokens.
References