How do #Solana tokens work? What are the Solana equivalents of ERC20 and ERC721? Let's find out πŸ‘‡
1/ In Ethereum, fungible tokens use the ERC20 standard, and non-fungible tokens use the ERC721 standard.

Each ERC20 token has its own smart contract, and each NFT collection has its own ERC721 contract.

Things work quite differently in Solana land.

2/ In order to understand Solana tokens, you need to understand Solana's account model.

Check out this thread if you're unfamiliar.

3/ In Solana, there is a single token program.

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). Image
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. Image
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. Image
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 πŸ˜›

pencilflip.medium.com/solanas-token-…

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with pencilflip.sol πŸ„ (πŸ“œ,πŸ“œ)

pencilflip.sol πŸ„ (πŸ“œ,πŸ“œ) Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @pencilflip

14 Nov
The 🍬 Candy Machine 🍬 is a program built by @redacted_j and @baalazamon that's commonly used to mint Solana NFT collections.

This thread is about how the program works (not how to use the Candy Machine for your own collection).

Let's go! πŸ‘‡
1/ First, if you want a simpler, shorter explanation, check out this comic!

2/ Now, some preliminary resources.

If you don't understand Solana's account model, check out this thread

Read 38 tweets
12 Nov
gm πŸ„ Excited to share @TheMycoverse, the project @petrichorate and I are working on!

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.
Read 4 tweets
10 Nov
How do NFT whitelists work on Ethereum? It's pretty simpleβ€”let's take a look at the @smilesssvrs smart contract to see how they did it πŸ‘‡

1/ The contract has a state variable called "_mintStatus."

This determines whether minting is only open to people on the whitelist (Acts 1-4), or is open to the public (Public 1-2).

Each status is associated with a minting limit. E.g. during Act 1, one person can mint 9 NFTs. Image
2/ Only the owner of the smart contract is allowed to change the status. Image
Read 10 tweets
3 Nov
PDAs, or program derived addresses, are one of the trickier #Solana concepts πŸ€”. They're also something that every Solana dev should understand.

In this thread, I'll go over what they are, and why they're useful πŸ‘‡
1/ First of all, if you don't know how Solana's account model works, check out this thread. It's only 5 tweets!

2/ Now, onto PDAs, or program derived addresses.

The name is pretty self-explanatoryβ€”a PDA is an address derived from a program.

The address points to a data account, which can hold state.
Read 37 tweets
25 Oct
Proof of Stake is used by #Solana and Ethereum 2.0. But what is Proof of Stake, and how does it work? A short thread πŸ‘‡
1/ "Proof of stake is a type of consensus mechanism used by blockchain networks to achieve distributed consensus."

In other words, Proof of Stake enables nodes in a blockchain network to agree on the state of the blockchain.
2/ For example, nodes should agree on:

- Which blocks are included in the blockchain
- Which transactions are included in each block
Read 12 tweets
24 Oct
#Solana accounts explained in 5 tweets πŸ‘‡
1/ There are 2 kinds of accounts in Solana.

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.
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Thank you for your support!

Follow Us on Twitter!

:(