Step-by-Step Tutorial for Setting Up Rust and Managing SPL Tokens on Solana
Step-by-Step Tutorial for Setting Up Rust and Managing SPL Tokens on Solana
1. Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2. Install SPL Token CLI
cargo install spl-token-cli
3. Set Rust Compiler Version
rustup override set 1.77.2
4. Reinstall SPL Token CLI (if necessary)
cargo install spl-token-cli
5. Install Solana
sh -c "$(curl -sSfL https://release.solana.com/v1.18.4/install)"
6. Update Path Environment Variable
export PATH="/Users/spuriousdragon/.local/share/solana/install/active_release/bin:$PATH"
7. Create a New Solana Wallet
Follow the guide to create a new wallet using your seed phrase or a hardware wallet: Guide to Solana Keypair Conventions
Command to create a new wallet:
solana-keygen new
8. Fund Your Wallet
Send some SOL (not ETH, as Solana uses SOL for transactions) to your wallet's address.
9. Create a New SPL Token
spl-token create-token
Save the generated token address.
10. Check Token Supply
spl-token supply <token_address>
This should return 0 initially.
11. Create a Token Account
spl-token create-account <token_address>
Save the new account address.
12. Mint Tokens
spl-token mint <token_address> <number_of_tokens> <account_address>
Gas fees are required for this operation.
13. Check Token Balance
spl-token balance <token_address>
14. Disable Further Minting
spl-token authorize <token_address> mint --disable
Verify if further minting is disabled to ensure it worked correctly.
15. Burn Tokens
spl-token burn <token_address> <number_of_tokens>
16. View Token Account Info
spl-token account-info <token_address>
17. Transfer Tokens
spl-token transfer --fund-recipient <contract_address> <amount> <recipient_address>
18. Install Metaboss for Metadata Management
19. Prepare Metadata JSON File
Create a metadata.json file with the following content:
{
"name": "TokenName",
"symbol": "TKN",
"description": "Description of the token.",
"image": "https://example.com/path/to/image.png",
"extensions": {
"website": "https://example.com",
"twitter": "https://twitter.com/example"
}
}
Replace the placeholders with appropriate values.
20. Host Metadata JSON File
Upload the metadata.json file to a Content Delivery Network (CDN) or a web server where it can be publicly accessed. Ensure the URL to the JSON file is correct and accessible.
For example, if you upload it to a CDN, the URL might look something like this:
https://example-cdn.com/path/to/metadata.json
Use this URL in the uri field of your metadata JSON file.
21. Create Metadata Using Metaboss
metaboss create metadata -a <token_address> -m https://example-cdn.com/path/to/metadata.json --rpc https://api.mainnet-beta.solana.com
22. Change Ownership of SPL Token
If you want to change the ownership of the contract or SPL token, use the following command:
spl-token authorize <token_address> mint --new-owner <new_owner_public_key>
These steps should guide you through creating and managing an SPL token on Solana, including adding metadata to your token and changing its ownership.
If you found this tutorial helpful and would like to support my work, consider donating to:
Solana Address: FdDRBkAcbQdH56MXyPD495R73TbzCoeRYZusVnHaGk36
Thank you!
Support SpuriousDragon