Skip to content

internet-court/internet-court-skill / vendored/sendaifun/birdeye

birdeye

Verified

Complete Birdeye API integration for real-time DeFi data across Solana and 15 other chains. Use for token prices, OHLCV charts, market discovery, on-chain trader intelligence, holder analysis, wallet portfolio & P&L, and WebSocket streams for live prices and whale alerts.

examples/token-data/token-security.ts

View on GitHub
/**
 * Token Security Check — Birdeye /defi/token_security
 * 
 * Detects honeypots, suspicious mint authority, and high creator concentration.
 * Use before recommending any token to flag rug risks.
 */

const TOKEN_ADDRESS = process.env.TOKEN_ADDRESS || "So11111111111111111111111111111111111111112";
const BIRDEYE_API_KEY = process.env.BIRDEYE_API_KEY!;

// Response fields per official /defi/token_security docs + live responses.
// Mint authority: the field is `isMintable` (not `mintable`). It's often null on
// established tokens; treat a non-null truthy value as active mint authority.
interface SecurityResult {
  ownerAddress: string | null;
  ownerBalance: number;
  ownerPercentage: number;
  creatorAddress: string | null;
  creatorBalance: number;
  creatorPercentage: number;
  isMintable: boolean | string | null;
  freezeable: boolean | null;
  freezeAuthority: string | null;
  mutableMetadata: boolean;
  nonTransferable: boolean | null;
  transferFeeEnable: boolean | null;
  isTrueToken: boolean | null;
  fakeToken: unknown;
  totalSupply: number;
  top10HolderBalance: number;
  top10HolderPercent: number;
}

async function checkTokenSecurity(address: string): Promise<void> {
  const url = `https://public-api.birdeye.so/defi/token_security?address=${address}`;

  const res = await fetch(url, {
    headers: {
      "X-API-KEY": BIRDEYE_API_KEY,
      "x-chain": "solana",
      "Accept": "application/json",
    },
  });

  if (!res.ok) throw new Error(`API Error ${res.status}: ${res.statusText}`);
  const json = await res.json() as any;
  const data: SecurityResult = json.data;

  console.log("=== TOKEN SECURITY REPORT ===");
  console.log(`Address: ${address}`);
  console.log(`Is True Token:      ${data.isTrueToken}`);
  console.log(`Mintable:           ${Boolean(data.isMintable)}`);
  console.log(`Freezeable:         ${Boolean(data.freezeable)}`);
  console.log(`Freeze Authority:   ${data.freezeAuthority ?? 'none'}`);
  console.log(`Mutable Metadata:   ${data.mutableMetadata}`);
  console.log(`Transfer Fee On:    ${Boolean(data.transferFeeEnable)}`);
  console.log(`Creator Holds:      ${((data.creatorPercentage ?? 0) * 100).toFixed(2)}%`);
  console.log(`Top 10 Holders:     ${((data.top10HolderPercent ?? 0) * 100).toFixed(2)}%`);

  // Risk flags
  if (data.isMintable) {
    console.warn("⚠️  WARNING: Mint authority is active — inflation risk.");
  }
  if (data.freezeable || data.freezeAuthority) {
    console.warn("⚠️  WARNING: Freeze authority is still set — tokens could be frozen.");
  }
  if (data.transferFeeEnable) {
    console.warn("⚠️  WARNING: Transfer fee enabled — swaps may bleed on each move.");
  }
  if ((data.creatorPercentage ?? 0) > 0.20) {
    console.warn(`⚠️  WARNING: Creator holds ${(data.creatorPercentage * 100).toFixed(1)}% — rug risk.`);
  }
  if ((data.top10HolderPercent ?? 0) > 0.50) {
    console.warn(`⚠️  WARNING: Top 10 holders control ${(data.top10HolderPercent * 100).toFixed(1)}% — concentration risk.`);
  }
  if (
    (data.creatorPercentage ?? 0) < 0.05 &&
    !data.isMintable &&
    !data.freezeable && !data.freezeAuthority &&
    !data.transferFeeEnable && data.isTrueToken
  ) {
    console.log("✅ Token appears safe — low creator %, no mint authority, no freeze authority, no transfer fee.");
  }
}

checkTokenSecurity(TOKEN_ADDRESS).catch(console.error);
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall