Tokens with gage
- solana programs are composable i.e most them sort use this thing call
Factory Patten - so, this means - The
Programwill allow users to createAccountsand do special things with those accounts.
SPL Token program
if will look how the factory pattern works in context of SPL token program
SPL Token Programis the factory forMint AccountsFrom
SPL Token Programusers can createMint Accounts(which will be set asauthorityof that account but still owned bySPL token program).And from
MInt Accountsusers can createToken Accounts. Also,Mint Accountsgonna have theAccounts,Decimals,Meta Data…Mint Accountis a factory forToken AccountsWith
Token Accountsthey can do things likeMint tokens,Transfer tokensandBurn Tokens…more on
SPL Token Programfactory pattern here.png)
Tansfer Tokens
- to transfer tokens users can ask
SPL tokensto send their tokens(which they got authority on), to other users.
Tokens in context of NFTs
we have
SPL tokensthat are nowtiedtoanother program's accountmost commonlyMetaPlexthe Metadata program.Non-Fungible tokens - An NFT is simply a
token type where only a single tokenhas beenminted.
The Token Program
- Tokens on solana are made and managed using
Solana token program- one of few programs inSolana Program Library(SPL) - both regular
tokensandNFTsareSolana program library tokens(SPL) tokens
Account relationships
3essential accounts for token program
1. wallet account: ur wallet 2. mint account : stores metadata about token mint. 3 .token account: tied to wallet and stores how many tokens the wallet has.
more here with the image

lets see all 3 one by one
1. Mint Account
- owner of
mint accountisToken Program - the
metadatait containsabout the tokenare here as follows:mint authority: theonly accountthat cansignandmint tokensfreeze authority: theone personorprogram authoritytofreezeormint.(to mint? is it kinda the same thing with mint authority?)decimal: Decimals is how many decimal places do we allow tokens to be broken up into - the precision with our tokens. I guess what decimal with2mean is like you can send32.03,1.23its about decimals after the decimal point?supply: how many tokens exist?is initialized: it has to do with accountnot with token. like is this account ready to go?
_It’s pretty standard to set the mint authority to your wallet, mint everything you want, and then remove the mint authority to basically say no more supply will be issued in the future. Alternatively, if you have some kind of dynamic issuance of tokens, it would be common to put them into authority as a program that program manages the minting of tokens.
The freeze authority works the same way._
- more in the image here:

2. Token Accounts (Associated Token Accounts(ATAs))
should be associated with user or wallet. In order to achieve this you will need to create PDA(Program driven Account) which gonna link
user/walletandmint accountto thetokenminted. And that’s gonna get asATAsthe seeds for PDA obviously
user wallet addressandmint account, token program id is there by default.more with picture here:
.png)
The token minting process
step one create a
mint accountstep two put up
mint accountandwallet addressto derivePDAto get Associated Token Account.you can easily do this with the sdk
@solana/spl-tokenhere is what mint looks like
1 | const mint = await createMint( |
connection- theJSON-RPCconnection to the clusterpayer- the keypair of the payer for the transactionmintAuthority- the account which is authorized to mint new tokensfreezeAuthority- an account authorized to freeze the tokens in a token account. If you don’t wanna be able to freeze, set it to null!decimals- specifies the desired decimal precision of the tokenOnce a
mint accountis createdcreate
Associated Token Accountsmint tokens to the
Associated Token Accountthen if u want with
transfer instructionyou can airdrop tokens to different accounts.note: if u wanna mint a token with a different transaction instruction you can do that as well.
Mint tokens on Solana
- Remember these steps:
- create
a mint token account - create
associated account for the wallet - you
mint tokens to that wallet
- create
Metaplex
Metaplexis a metadata store for solanametadatacould beimagefor your token, where thatimageis stored…Metaplexis gonna handle all of the associated data for theAssociated token account

- So, from the image above we can see that:
Metaplexhas:Metadata Account: that’s gonna store metadata about token. This account is usually used forfungible tokenslike USDC or anNFT(non fungible token)that has the same artwork. Contains the following metadataURI,Symbol,Price,Royalities,CreatorsMaster Edition Account: is used for an NFT that hasone type of artwork. Different piece of artwork. Also, it has aCollection token accountwhich is to sayhey this NFT belongs to this specific collection. Also, aCollection token accounthasAuthority record accountwhich lets adifferent account(other than a creator)toaddNFTs to that specificCollection token account.
Token Metadata
metadatais set of data that describes about another dataso,
token metadatais metadata about the token. likename,symbol,logo…On Solana, NFTs are just like other tokens but
metadatadefines themas NFTs via attributes such as decimals.attaching metadata to token is done using
Token Metadata Program. It does this by usingPDAsthat are derived fromMint accounts
Token Metadata Account
stores different info about the
Mint token accountNotice the
URIproperty onMetadata account? - it points tooff-chainJSONfile, mainly used for NFT. Since theJSON is off-chainyou can storehigh qualitymedias.
Token standard
the
off-chainpart followsMetaplex token standard.we tell what
Token Standardwe’re using usingToken Standardon-chain field onToken Metadata AccountToken standardoptions:NonFungible: a non-fungile token withMaster Edition(NFTs)FungibleAsset: a fungible asset with metadata, that also haveattributes. AKA,Semi-Fungibleex: game itemsFungible: a fungible token with metadata. ex: (USDC, SOL, your own token)NonFungibleEdition: a non-fungible token withEdition Account.(printed from Master Edition.Like 1 out of 100)
Metaplex Token Standardis widely accepted and various exchanges needs you to conform to it.Here is how it knows which
Token Standardis being used:- if token has
Master Edition accountit isNonFungible - if token has
Edition Accountit isNonFungibleEdition - if token has
NOMaster or Edition Account,ensuring its supply can be > 1, and uses0decimal places - it isFungibleAsset. Because if you think about it a good example could begame collectiblesand you cannot divide those more than a whole number. You cannot have 2.31 game collectibles. They are represented by whole numbers only. - if token NO
Master or Edition Account,ensuring its supply can be > 1and uses atleast1decimal places, - it isFungible
- if token has
Here is an example of
Fungible token standard
Metaplex SDK
One of the most used SDKs on Solana.
We’ll be using
@metaplex-foundation/jsand@metaplex-foundation/mpl-token-metadatato createmetadata account associated with our token mint.general flow for attaching metadata for
FungibleTokencould be sth like this:
- setup Metaplex SDK
- Upload image for the logo
- Upload the off-chain metadata
- Derive the Metadata Account PDA
- Create on-chain Metadata Token Account