pages/index.json

1 line
76 KiB
JSON
Raw Normal View History

2024-03-15 23:43:34 -04:00
[{"content":"I wanted to create an SPL token and after looking online I couldn\u0026rsquo;t find an updated guide. So I thought I would learn and share. There are much easier ways to create these tokens but they cost $ and spending more $ than needed is no fun. This guide costs as little SOL as possible as everything is transacted directly on-chain. Everything is done from the CLI.\nThis guide just covers the basics, the tools used are way more powerful than what I use them for, this is just creating a basic token with no taxes or locked supply or anything complex, but these tools do support those options. If you are interested in doing more I would read the proper documentation.\nhttps://docs.solanalabs.com/cli/install https://metaboss.rs/overview.html https://spl.solana.com/token NetworkChuck has a video from late 2021 on doing this, but some commands are a bit outdated, and Solana updated their entire metadata process in 2022.\nI am using an Ubuntu 22.04 VM with 60GB storage to run these commands.\nStarting balance: 0.079975 SOL Ending balance: 0.05731652 SOL Total SOL cost: 0.02265848 SOL ($4.22 on 3/15/2024) Installing Solana Tools First we need to download Solana tools to our system:\nsh -c \u0026#34;$(curl -sSfL https://release.solana.com/stable/install)\u0026#34; then run the export path command that is given to you:\nexport PATH=\u0026#34;/home/mafyuh/.local/share/solana/install/active_release/bin:$PATH\u0026#34; Restart your terminal session.\nCreating Wallet We will create a new SOL wallet to fund our token. To do this run:\nsolana-keygen new You don\u0026rsquo;t have to put a passphrase if you don\u0026rsquo;t want to. I would backup your recovery seed phrase and take note of the public address. I would fund this wallet with some SOL as well at this time.\nKeep note of the keypair directory for later step.\nCheck your SOL balance with:\nsolana balance Install Rust We need Rust in order to create the token, to install Rust run:\ncurl --proto \u0026#39;=https\u0026#39; --tlsv1.2 -sSf https://sh.rustup.rs | sh Press enter for default installation. Once completed, restart your session again.\nThen we need to install some needed packages:\nsudo apt install libudev-dev llvm libclang-dev libssl-dev pkg-config build-essential protobuf-compiler -y Install spl-token-cli Now using Rust we are gonna install Solana\u0026rsquo;s CLI tools, this will take a few minutes.\ncargo install spl-token-cli Create Token Creating a new token is simple, make sure your wallet is funded with SOL and just run:\nspl-token create-token Your token\u0026rsquo;s address will be printed on screen. You will use this address in pretty much all the rest of the steps so keep handy. You do need to have your wallet funded first.\nNow we need to create a token account for this token:\nspl-token create-account \u0026lt;TOKEN_ADDRESS\u0026gt; Example:\nspl-token create-account 7njsg9BA1xvXX9DNpe5fERHK4zb7MbCHKZ6zsx5k3adr If you get errors like:\n\u0026ldquo;unable to confirm transaction. This can happen in situations such as transaction expiration and insufficient fee-payer funds\u0026rdquo;\nYou just need to retry a few times, it will eventually go thru but sometimes takes 3-4 runs.\nMinting Tokens Now that you have a token and an account for the token, you can actually mint some tokens. To do this run:\nspl-token mint \u0026lt;TOKEN_ADDRESS\u0026gt; \u0026lt;# of tokens\u0026gt; \u0026lt;ACCOUNT_ADDRESS\u0026gt; Example:\nspl-token mint 7njsg9BA1xvXX9DNpe5fERHK4zb7MbCHKZ6zsx5k3adr 1000000 CkaGbdriXVMHtzFBPtnpDjQvZ9gM9bwd8XdTTKR2Wx32 To see your tokens you can run:\nspl-token accounts Now you will want to send these tokens to a new address, so make a new wallet and get its pubkey, then to send these tokens run:\nspl-token transfer --fund-recipient --allow-unfunded-recipient \u0026lt;TOKEN_ADDRESS\u0026gt; \u0026lt;# of tokens\u0026gt; \u0026lt;NEW_ADDRESS\u0026gt; Example:\nspl-token transfer --fund-recipient --allow-unfunded-recipient 7njsg9BA1xvXX9DNpe5fERHK4zb7MbCHKZ6zsx5k3adr 1000000 2DDyEt5N4y77ETWhhUmkZiympQbpjkfrt8FcMKhB1iWU Installing Metabos