This guide demonstrates how to create Solana Program Library (SPL) tokens on the SOON. We’ll use the Metaplex Foundation’s UMI framework and MPL Token Metadata program to create our token.

Introduction

In this guide, you’ll learn how to create your own SPL token on SOON’s testnet.

You can find the complete code for this guide on GitHub.

Prerequisites

Before you begin, make sure you have:

  • Node.js (v14 or higher)
  • pnpm package manager
  • Basic understanding of Solana and SPL tokens
  • A wallet funded with testnet SOON tokens

Implementation

Let’s understand how to create an SPL token by breaking down the code:

import {
  percentAmount,
  generateSigner,
  some,
  createSignerFromKeypair,
  signerIdentity,
} from "@metaplex-foundation/umi";
import { createFungible } from "@metaplex-foundation/mpl-token-metadata";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";
import { base58 } from "@metaplex-foundation/umi/serializers";

// Initialize UMI with SOON testnet
const umi = createUmi("https://rpc.testnet.soo.network/rpc");

// Payer secret key for signing transactions
const payerSecretKey = new Uint8Array([]);

// Create keypair and signer
let keypair = umi.eddsa.createKeypairFromSecretKey(payerSecretKey);
const payer = Keypair.fromSecretKey(payerSecretKey);
console.log("Payer Public Key:", payer.publicKey.toBase58());
const balance = await umi.rpc.getBalance(keypair.publicKey);
console.log(
  "Payer Balance:",
  (Number(balance.basisPoints) / LAMPORTS_PER_SOL).toFixed(2),
  "SOL"
);

const myKeypairSigner = createSignerFromKeypair(umi, keypair);
umi.use(signerIdentity(myKeypairSigner));

// Create a mint signer
const mint = generateSigner(umi);

// Main function to create a fungible token
async function main() {
  // Create the fungible token
  const txResponse = await createFungible(umi, {
    mint,
    name: "BONK",
    uri: "https://idylufmhksp63vptfnctn2qcjphffwwryc5cbw4wd2xnyiqzf3ga.arweave.net/QPC6FYdUn-3V8ytFNuoCS85S2tHAuiDblh6u3CIZLsw",
    sellerFeeBasisPoints: percentAmount(5.5),
    decimals: some(7),
  }).sendAndConfirm(umi);

  const txHash = base58.deserialize(txResponse.signature);
  console.log("newly created mint:", mint.publicKey);
  console.log("Transaction hash:", txHash);
}

main().catch(console.error);

Code Breakdown

  1. UMI Initialization:

    const umi = createUmi("https://rpc.testnet.soo.network/rpc");
    

    This creates a new UMI instance connected to SOON’s testnet. The UMI framework provides a convenient way to interact with the SOON blockchain.

  2. Keypair Setup:

    const payerSecretKey = new Uint8Array([...]); // Replace with your secret key
    let keypair = umi.eddsa.createKeypairFromSecretKey(payerSecretKey);
    

    Here we create a keypair from your wallet’s secret key which will be used to sign transactions. The script also checks and displays your wallet balance.

  3. Token Creation:

    const txResponse = await createFungible(umi, {
      mint,
      name: "BONK",
      uri: "your-metadata-uri",
      sellerFeeBasisPoints: percentAmount(5.5),
      decimals: some(7),
    });
    

    This creates the actual token with the following parameters:

    • mint: A new generated signer for the token
    • name: The name of your token
    • uri: Link to your token’s metadata (usually hosted on Arweave/IPFS)
    • sellerFeeBasisPoints: Royalty percentage (5.5% in this case)
    • decimals: Number of decimal places for the token (7 in this case)

Using the Code

To create your own token:

  1. Set your wallet’s secret key in the payerSecretKey array
  2. Modify the token parameters in the main() function:
    • name: Your token’s name
    • uri: Link to your token’s metadata
    • sellerFeeBasisPoints: Seller fee percentage
    • decimals: Number of decimal places

When you run the script, you’ll see output like:

Payer Balance: 1.50 SOL
Payer Public Key: 5KoJj9WzpKwYkrsKyKqkq5YvK4qNxPk8hZ4ZKs4qKx5h
newly created mint: 7n8SJg3m4FtPNrYxnmki9kmgZuVDyYr6DqqY8zcaErj
Transaction hash: 2ZFj9EkvCyQvnc3Z3GXjqyEQNNtHxW9BRRYPvYhYd7C6WxkJe4YVhJUn3L8jx8

Network Configuration

SOON provides different networks for development and testing:

  • Devnet: https://rpc.devnet.soo.network/rpc
  • Testnet: https://rpc.testnet.soo.network/rpc

To switch networks, simply update the UMI initialization URL.

Additional Resources