banner
[面包]MrTwoC

[面包]MrTwoC

你好,欢迎来到这个基于区块链的个人博客 名字:面包 / MrTwoc 爱好:跑步(5/10KM)、咖啡、游戏(MMORPG、FPS、Minecraft、Warframe) 兴趣方向:Rust、区块链、网络安全、量子信息(量子计算)、游戏设计与开发
bilibili
steam
email
github

Solana.4.Token Minting

Reference Address 1: Solana Mint Token
Reference Address 2: Configuration Mirror Download Address: RsProxy
Reference Address 3: Solna-CLI Official Documentation

Environment Preparation:#

  1. Rust Environment
  2. Solana CLI
  3. spl-token-cli

Rust Environment Installation:#

For details, please see {Reference Address 2}

Solana CLI Installation:#

Please see the previous article "Solana.3"

spl-token-cli Installation:#

Note: Please configure the mirror address in {Reference Address 2} before installation, otherwise, download failures may occur.
Open cmd and use cargo to download

cargo install spl-token-cli

Environment Check#

If all display version numbers, it can be considered installed successfully.

rustc -V
Solana -V
spl-token -V

image.png

Official Steps#

Connect to Solana Developer Network#

For details, see {Reference Address 3}

solana config set --url https://api.devnet.solana.com

image.png

Create Wallet#

solana-keygen new

It will display the following content
image.png
The id.json file is the private key file

Wrote new keypair to C:\Users\Administrator\.config\solana\id.json
===============================================================================
pubkey: FRSQkdoEQ8opdhfF93nwa8xa261Gj667NR6HE5BiZDaz
===============================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
This is a set of 12 words, which are private mnemonic words that should not be made public.
===============================================================================

Public Key: Used for deploying smart contracts, etc.
FRSQkdoEQ8opdhfF93nwa8xa261Gj667NR6HE5BiZDaz
Enter in cmd

solana-keygen pubkey

It will display the public key generated earlier

C:\Users\Administrator>solana-keygen pubkey
FRSQkdoEQ8opdhfF93nwa8xa261Gj667NR6HE5BiZDaz

Claim/Test Tokens#

solana airdrop 2		//Claim two test tokens
solana balance 			//Check current balance

//You can also claim test tokens through the following website
https://solfaucet.com/

image.png
b299cd6f82d4857b5789768a62333ba3.png

Create Token#

spl-token create-token
C:\Users\Administrator>spl-token create-token
Creating token HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF under program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

Address:  HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF
Decimals:  9

Signature: 2FHJH8YHpGWST91qvqwK1HY9ipsn4yuhBhpdeQnY113DQq5RW2CS7GKGWd6PyzRjGtg88fBraqqjKmCXi9ZPq9RS

Address Token Address: HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF

Create Account to Store Tokens#

spl-token create-account <token address>
C:\Users\Administrator>spl-token create-account HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF
Creating account 4tGEWvngsN261cEJDsUuK1ssXPu9RM2RfQ9YSG9L3XKt

Signature: 5yxhgRWzNWpWxW4W4CwT6pvWbe9X7hZppxXy1KynTDpFMacPWZCFADUc5JJateWZz1ZQEy9tN7XcFNFUjhRTAe8w

Get Token Account
4tGEWvngsN261cEJDsUuK1ssXPu9RM2RfQ9YSG9L3XKt

Mint Token#

spl-token mint <token address> <token amount>

image.png

C:\Users\Administrator>spl-token mint HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF 100
Minting 100 tokens
  Token: HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF
  Recipient: 4tGEWvngsN261cEJDsUuK1ssXPu9RM2RfQ9YSG9L3XKt

Signature: 5jGdumQsKePWYM51Ed9wxgtNQbJ6ZgVMwv2eBxUvJnW5nr5v6SyaDG4QSqamky37qfCnRXmtvapbRNYoLdgfSzXM

After completion, you can check the token address on solscan.io and see a mint transaction with a total of 100
image.png
Then check the token account address, which also has a mint transaction.
image.png

Token Balance Inquiry#

spl-token balance <token address>

//Example:
C:\Users\Administrator>spl-token balance HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF
100

image.png

Disable Further Minting#

spl-token authorize <token address> mint --disable

//Example:
spl-token authorize HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF mint --disable
C:\Users\Administrator>spl-token authorize HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF mint --disable
Updating HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF
  Current mint: FRSQkdoEQ8opdhfF93nwa8xa261Gj667NR6HE5BiZDaz
  New mint: disabled

Signature: 34pi1mP5gMooct9P5s3KdzGwPaDQ5rqusbUejKzqytVjnfBt34B2ZpQ6uN7F2qmTaytp2avay2Hi3WUQByp4HeWr

If you try to mint again, an error will be reported.

Import Private Key into Phantom#

About Phantom:
Phantom is a feature-rich, thoughtful, and easy-to-use decentralized wallet tool in the Solana ecosystem. It not only supports the Solana chain but the team has also completed integration with the Bitcoin network, thus supporting digital assets such as BTC, BRC-20, Ordinals, and is compatible with Segwit and Taproot addresses. This means users can now use the Phantom wallet to directly purchase inscriptions on Magic Eden and send/receive Taproot assets.
The Phantom wallet is available in web plugin, iOS, and Android versions, and has become the preferred wallet for users participating in various Solana applications. Its main features include token swaps, collecting NFT collectibles, connecting hardware wallets, and staking SOL for rewards. Additionally, Phantom aims to connect with more networks and is currently building compatibility with Ethereum and supporting other blockchains, aiming to create a "multi-chain world" in the wallet ecosystem.
Open Phantom in the browser, click to add/link wallet
image.png
Copy the content from the id.json file created earlier into it.
image.png
Click import, then click [Settings] -> [Developer Settings] -> Turn on [Testnet Mode]
Return to the Phantom homepage, and you will see your minted tokens.
image.pngimage.png

Query on Solscan#

//Token Address:
HS82QAxERdbQvRnJgNmCCKCKNkJffNW5cSLMGaYbuEHF

image.png

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.