DeveloperBreeze

Spl Token Program Development Tutorials, Guides & Insights

Unlock 2+ expert-curated spl token program tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your spl token program skills on DeveloperBreeze.

Using Solana's Program Library: Building Applications with Pre-Built Functions

Tutorial August 27, 2024
rust

  • Token Program: Manages and interacts with tokens on the Solana blockchain. It supports minting, transferring, burning, and freezing tokens.
  • Associated Token Account Program: Creates and manages associated token accounts for users.
  • Memo Program: Allows developers to attach arbitrary data to transactions.
  • Token Swap Program: Enables token swapping functionalities similar to those found in decentralized exchanges (DEXs).

Let's start by creating a new project using the Anchor framework.

Tracking Newly Created Tokens on Solana

Tutorial August 09, 2024
javascript nodejs

Solana tokens are created using the SPL Token Program, so we'll track transactions involving this program to identify new tokens. Add the following function to your index.js file:

async function getNewTokens(startSlot) {
  try {
    const currentSlot = await connection.getSlot();
    const signatures = await connection.getConfirmedSignaturesForAddress2(
      new solanaWeb3.PublicKey(solanaWeb3.TOKEN_PROGRAM_ID),
      { startSlot, limit: 100 }
    );

    console.log('Newly Created Tokens:');
    for (const signatureInfo of signatures) {
      const transaction = await connection.getConfirmedTransaction(signatureInfo.signature);
      const transactionInstructions = transaction.transaction.message.instructions;

      transactionInstructions.forEach((instruction) => {
        if (instruction.programId.equals(solanaWeb3.TOKEN_PROGRAM_ID)) {
          const data = Buffer.from(instruction.data);
          const command = data.readUInt8(0);

          // Command 1 represents the Token Mint To instruction
          if (command === 1) {
            const mintAccount = instruction.keys[0].pubkey.toBase58();
            console.log(`- New Token Mint: ${mintAccount}`);
          }
        }
      });
    }
  } catch (error) {
    console.error('Error fetching new tokens:', error);
  }
}

// Replace with the starting slot number
const startSlot = 1000000;
getNewTokens(startSlot);