Home / Integration Guide

SDA Token Integration Guide

Complete implementation guide for integrating SDA Token into wallets, exchanges, and decentralized applications. Learn how to handle compliant transfers, display balances, and implement best practices.

Prerequisites

Quick Start (JavaScript/TypeScript)

Integrate SDA Token into your application using the official Solana libraries.

1Install Dependencies

# Using npm
npm install @solana/web3.js @solana/spl-token

# Using yarn
yarn add @solana/web3.js @solana/spl-token

2Initialize Connection

import { Connection, PublicKey } from '@solana/web3.js';
import {
  getAssociatedTokenAddress,
  getAccount,
  TOKEN_2022_PROGRAM_ID
} from '@solana/spl-token';

const connection = new Connection(
  'https://api.mainnet-beta.solana.com',
  'confirmed'
);

// SDA Token mint address (Token-2022)
const SDA_MINT = new PublicKey('SDAmxfpgaGmtxTqcTcvr4yi2kBwEFxTLF2XU4oLFw4b');

3Get Token Balance

async function getTokenBalance(walletAddress) {
  const wallet = new PublicKey(walletAddress);

  // Get the Associated Token Account (ATA) for Token-2022
  const ata = await getAssociatedTokenAddress(
    SDA_MINT,
    wallet,
    false,  // allowOwnerOffCurve
    TOKEN_2022_PROGRAM_ID  // Token-2022 program
  );

  // Fetch balance using RPC
  const tokenAmount = await connection.getTokenAccountBalance(ata);

  console.log(`Balance: ${tokenAmount.value.uiAmount}`);
  console.log(`Raw amount: ${tokenAmount.value.amount}`);
  console.log(`Decimals: ${tokenAmount.value.decimals}`);

  return tokenAmount.value.uiAmount;
}

// Example usage
getTokenBalance('GgkjCVbnDUpsp86mWSqtw6TgRSh7FTLUaNzchWhs1ZyP');

4Get All Token-2022 Accounts for Wallet

async function getAllToken2022(walletAddress) {
  const wallet = new PublicKey(walletAddress);

  // Get Token-2022 accounts (SDA Token uses Token-2022)
  const response = await connection.getParsedTokenAccountsByOwner(
    wallet,
    { programId: TOKEN_2022_PROGRAM_ID }
  );

  response.value.forEach((accountInfo) => {
    const data = accountInfo.account.data.parsed.info;
    console.log(`Mint: ${data.mint}`);
    console.log(`Balance: ${data.tokenAmount.uiAmount}`);
  });

  return response.value;
}

Ownership Verification

Verifying token ownership is crucial for access control and governance participation.

import {
  getAssociatedTokenAddress,
  getAccount,
  TOKEN_2022_PROGRAM_ID
} from '@solana/spl-token';

async function verifyOwnership(walletAddress, minBalance = 0) {
  const wallet = new PublicKey(walletAddress);

  try {
    // Get the Associated Token Account for Token-2022
    const ata = await getAssociatedTokenAddress(
      SDA_MINT,
      wallet,
      false,
      TOKEN_2022_PROGRAM_ID
    );

    // Fetch account info (throws if account doesn't exist)
    const tokenAccount = await getAccount(connection, ata, 'confirmed', TOKEN_2022_PROGRAM_ID);

    // Calculate human-readable balance (assuming 6 decimals)
    const balance = Number(tokenAccount.amount) / 1e6;

    return {
      isHolder: balance > 0,
      balance: balance,
      meetsRequirement: balance >= minBalance,
      tokenAccount: ata.toBase58(),
      owner: tokenAccount.owner.toBase58()
    };
  } catch (error) {
    // Account doesn't exist = not a holder
    return {
      isHolder: false,
      balance: 0,
      meetsRequirement: false,
      tokenAccount: null,
      owner: null
    };
  }
}

// Example: Check if wallet holds at least 100 SDA
const result = await verifyOwnership(
  'GgkjCVbnDUpsp86mWSqtw6TgRSh7FTLUaNzchWhs1ZyP',
  100
);
console.log(result);

Transfer Implementation

Implementing SPL token transfers using the official Solana libraries.

import { Transaction, sendAndConfirmTransaction } from '@solana/web3.js';
import {
  getAssociatedTokenAddress,
  createTransferInstruction,
  getOrCreateAssociatedTokenAccount,
  TOKEN_2022_PROGRAM_ID
} from '@solana/spl-token';

async function transferTokens(fromKeypair, toAddress, amount) {
  const to = new PublicKey(toAddress);
  const decimals = 6; // SDA Token decimals
  const transferAmount = amount * Math.pow(10, decimals);

  // Get source token account (sender's ATA for Token-2022)
  const sourceAta = await getAssociatedTokenAddress(
    SDA_MINT,
    fromKeypair.publicKey,
    false,
    TOKEN_2022_PROGRAM_ID
  );

  // Get or create destination token account (recipient's ATA)
  const destAta = await getOrCreateAssociatedTokenAccount(
    connection,
    fromKeypair,  // payer for account creation if needed
    SDA_MINT,
    to,
    false,
    'confirmed',
    {},
    TOKEN_2022_PROGRAM_ID
  );

  // Create transfer instruction for Token-2022
  const transferIx = createTransferInstruction(
    sourceAta,           // source
    destAta.address,     // destination
    fromKeypair.publicKey, // owner of source
    transferAmount,      // amount in smallest units
    [],                  // multiSigners
    TOKEN_2022_PROGRAM_ID
  );

  // Build and send transaction
  const transaction = new Transaction().add(transferIx);
  const signature = await sendAndConfirmTransaction(
    connection,
    transaction,
    [fromKeypair]
  );

  console.log(`Transfer successful: ${signature}`);
  return { success: true, signature };
}

Exchange Integration

Exchanges require additional considerations for custody, compliance, and high-volume operations.

Integration Aspect Requirement Implementation
Wallet Structure Hot/Cold segregation Use multisig for cold storage
Deposits Monitor incoming transfers WebSocket subscription
Withdrawals Validate destination Check before processing
Reporting Transaction history Audit trail API endpoints

Python Integration

For Python developers, use the solana-py library to interact with SDA Token.

1Install Dependencies

# Install solana-py
pip install solana

2Get All Token-2022 Balances for Wallet

from solana.rpc.api import Client
from solders.pubkey import Pubkey
from solana.rpc.types import TokenAccountOpts

# Initialize RPC client
client = Client("https://api.mainnet-beta.solana.com")

# Token-2022 Program ID (SDA Token uses Token-2022)
TOKEN_2022_PROGRAM_ID = Pubkey.from_string(
    "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
)

def get_all_token2022(wallet_address: str):
    """Get all Token-2022 balances for a wallet."""
    wallet = Pubkey.from_string(wallet_address)
    opts = TokenAccountOpts(program_id=TOKEN_2022_PROGRAM_ID)

    response = client.get_token_accounts_by_owner_json_parsed(wallet, opts)

    tokens = []
    for account in response.value:
        info = account.account.data.parsed['info']
        tokens.append({
            'mint': info['mint'],
            'balance': info['tokenAmount']['uiAmount'],
            'decimals': info['tokenAmount']['decimals'],
            'account': str(account.pubkey)
        })
    return tokens

# Example usage
wallet = "GgkjCVbnDUpsp86mWSqtw6TgRSh7FTLUaNzchWhs1ZyP"
for token in get_all_token2022(wallet):
    print(f"Mint: {token['mint']}")
    print(f"Balance: {token['balance']}")
    print("---")

3Get Specific Token Balance

from solders.pubkey import Pubkey

# SDA Token mint address (Token-2022)
SDA_MINT = Pubkey.from_string("SDAmxfpgaGmtxTqcTcvr4yi2kBwEFxTLF2XU4oLFw4b")
TOKEN_2022_PROGRAM_ID = Pubkey.from_string("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")

def get_sda_balance(wallet_address: str):
    """Get SDA Token balance for a specific wallet."""
    wallet = Pubkey.from_string(wallet_address)
    # Use Token-2022 program for SDA Token
    opts = TokenAccountOpts(mint=SDA_MINT, program_id=TOKEN_2022_PROGRAM_ID)

    response = client.get_token_accounts_by_owner_json_parsed(wallet, opts)

    if not response.value:
        return 0.0  # No SDA token account found

    info = response.value[0].account.data.parsed['info']
    return info['tokenAmount']['uiAmount']

# Example usage
balance = get_sda_balance("GgkjCVbnDUpsp86mWSqtw6TgRSh7FTLUaNzchWhs1ZyP")
print(f"SDA Balance: {balance}")

4Get Balance by Token Account Address

def get_token_account_balance(token_account_address: str):
    """Get balance of a specific token account."""
    account = Pubkey.from_string(token_account_address)
    response = client.get_token_account_balance(account)

    return {
        'amount': response.value.amount,
        'decimals': response.value.decimals,
        'ui_amount': response.value.ui_amount
    }

# Example: Get balance of a known token account
result = get_token_account_balance("YOUR_TOKEN_ACCOUNT_ADDRESS")
print(f"Balance: {result['ui_amount']}")

Support Resources