This program is responsible for creating, minting, and transferring tokens.
So if you want to create a new type of token, instead of deploying a new ERC20 smart contract, you send the "create" instruction to the token program.
4/ Note: you may see Solana tokens referred to as "SPL tokens."
SPL stands for Solana Program Library, which is a set of Solana programs that the Solana team has deployed on-chain.
5/ SPL tokens are analogous to ERC20 tokens.
SPL token = a token created with the Solana token program
ERC20 token = a token whose smart contract uses the ERC20 standard
Both have a standard set of functionality.
6/ If you don't completely understand yet, don't worry! Going through an example should make things much clearer, which is what we'll do next.
7/ Now, onto the example.
Let's say I want to create a new type of fungible token, mint some to myself, and then transfer some to a friend. How does that work in Solana?
8/ First, we send the "create" instruction to the token program.
This creates a new "mint account."
Each type of token is associated with exactly one mint account, and the mint account holds metadata about the token (like its total supply and who is allowed to mint it).
9/ Next, we tell the token program to create a "token account." Each user may have one or more token accounts for each type of token.
A token account just stores how many tokens a particular user has, for a particular type of token.
10/ For example, if you own 10 of token1 and 5 of token2, you should have two token accounts.
11/ Onto minting! To mint, we just send the "mint" instruction to the token program, which tells the program how many tokens to mint and whom to mint them to.
Only one user is allowed to mint tokens of a particular type. This is determined when the token type is created.
12/ Minting tokens to someone just means that the balance in their token account goes up.
13/ To transfer tokens, we send the "transfer" instruction to the token program, which tells it how many tokens to transfer and whom to transfer them to.
Note that the recipient must also own a token account for the type of token you're transferring.
14/ Transferring tokens to someone just means the balance in their token account goes up, and your balance goes down.
15/ We covered a lot of material, so let's recap:
- Solana's token program is responsible for creating/minting/transferring tokens
- Each token type has one mint account, which stores metadata about the token
- Token accounts store the amount of tokens you own
16/ Just a few more things to cover!
Just like how ETH can be wrapped in an ERC20 token to form wETH, SOL can be wrapped in an SPL token.
Of course, the SPL token can also be unwrapped.
Wrapping SOL like this allows SOL to be easily exchanged for other SPL tokens.
17/ We've covered how fungible tokens work. But what about NFTs?
Solana NFTs use the same token program, but there are some differences in how they are created and minted.
18/ When an NFT is created, you specify that it has "zero decimals." You can have 0.01 of $SHIB, but you can't have 0.01 of a Cool Cats NFT. Thus, the amount of a NFT is always a whole number.
19/ Then, after a single NFT is minted, you disable future minting of the token type. This ensures there will only ever be one.
In practice, most people use Candy Machine to create NFTs, which abstracts all this complexity away.
20/ That's it! By now, you should understand how SPL tokens work, and how they differ from ERC20 and ERC721 tokens.
For a more thorough breakdown of this topic, check out my Medium post π
We're starting with a mushroom-inspired NFT collection (b/c mushrooms are awesome), but our larger goal is to help onboard more artists and creators into web3.
Right now, getting into web3 as an artist is hard π΅βπ«.
Which blockchain should you choose? Which marketplace should you list on? How do you make an NFT collection? How do you airdrop NFTs to people? How do you market yourself?
We're building a community that cares about helping artists. With that community, we'll create tools and resources that make it easy for any artist or creator to get started with web3.
Data accounts store data. Program accounts store executable programs.
Each account has an address (usually a public key) and an owner (address of a program account). There are a few more fields every account stores, see π
2/ There are a few important ownership rules:
- Only a data account's owner can modify its data and subtract lamports.
- Anyone is allowed to give lamports to a data account.
- The owner of an account may assign a new owner if the account's data is zeroed out.