@pompafly/sdk
v0.1.4
Published
TypeScript SDK for the Pompafly token launchpad on Solana
Maintainers
Readme
@pompafly/sdk
TypeScript SDK for the Pompafly token launchpad on Solana.
Install
npm install @pompafly/sdkQuick Start
Frontend (Next.js + Wallet Adapter)
import { PompaflyClient, PompaflyAPI, PompaflyStream, DEVNET_CONFIG } from "@pompafly/sdk";
import { useAnchorWallet } from "@solana/wallet-adapter-react";
// Transaction client
const wallet = useAnchorWallet();
const client = new PompaflyClient({ wallet, config: DEVNET_CONFIG });
// REST API
const api = new PompaflyAPI(DEVNET_CONFIG);
// Real-time stream
const stream = new PompaflyStream(DEVNET_CONFIG);Backend (Node.js + Keypair)
import { PompaflyClient, DEVNET_CONFIG } from "@pompafly/sdk";
import { Keypair } from "@solana/web3.js";
const keypair = Keypair.fromSecretKey(/* your secret key */);
const client = new PompaflyClient({ keypair, config: DEVNET_CONFIG });Usage
Browse Pools
// List trending pools
const { data: pools } = await api.getPools({ sort: "volume", status: "active" });
// Search by name
const { data: results } = await api.getPools({ search: "DOGE" });
// Get pool details
const { data: pool } = await api.getPool("mint_address_here");
// Get current price
const { data: price } = await api.getPoolPrice("mint_address_here");Buy Tokens
// Buy 100 tokens with 1 SOL max slippage
const result = await client.buy("mint_address", 100, 1.0);
console.log("Signature:", result.signature);
// Priority buy (during 120s window, requires auth)
const { data: auth } = await api.getPriorityAuth("mint_address");
const result = await client.buy("mint_address", 100, 1.0, prioritySignerKeypair);Sell Tokens
// Sell 50 tokens, accept any return
const result = await client.sell("mint_address", 50);
// Sell with minimum return of 0.5 SOL
const result = await client.sell("mint_address", 50, 0.5);Create a Token
const result = await client.createPool(
"My Token", // name
"MYTKN", // symbol
"https://meta.json", // metadata URI
"myxhandle", // X handle
authorityKeypair // backend co-signer
);
console.log("Mint:", result.mint);
console.log("Pool:", result.pool);Real-Time Price Feed
const stream = new PompaflyStream();
stream.connect();
// Subscribe to specific tokens
stream.subscribe(["mint1", "mint2"]);
// Listen for price updates
const unsub = stream.onPrice((event) => {
console.log(`${event.mint}: ${event.data.currentPrice}`);
});
// Listen for trades
stream.onTrade((event) => {
console.log(`${event.data.type}: ${event.data.tokenAmount} tokens`);
});
// Cleanup
unsub(); // remove listener
stream.unsubscribe(["mint1"]);
stream.disconnect();Authentication Flow
// 1. Get nonce
const { data: { nonce, message } } = await api.getNonce(wallet.publicKey.toBase58());
// 2. Sign with wallet (frontend)
const signature = await wallet.signMessage(new TextEncoder().encode(message));
// 3. Verify and get JWT
const { data: { token, user } } = await api.verifyWallet(
wallet.publicKey.toBase58(),
bs58.encode(signature)
);
// JWT is automatically stored in the API client
// 4. Link X account (redirects to Twitter OAuth)
window.location.href = api.getXLoginUrl();Charts
// Get 1-hour candles for the last 24 hours
const { data: candles } = await api.getCandles("mint_address", {
interval: "1h",
from: Math.floor(Date.now() / 1000) - 86400,
limit: 24,
});Platform Stats
const { data: stats } = await api.getStats();
console.log("Total pools:", stats.totalPoolsCreated);
console.log("Graduation rate:", stats.graduationRate);
const { data: trending } = await api.getTrending(10);Utilities
import { solToLamports, lamportsToSol, tokensToBase, baseToTokens } from "@pompafly/sdk";
solToLamports(1.5); // 1500000000
lamportsToSol(1500000000); // 1.5
tokensToBase(100); // 100000000
baseToTokens(100000000); // 100Configuration
import { DEVNET_CONFIG, MAINNET_CONFIG } from "@pompafly/sdk";
// Or custom config
const config = {
rpcUrl: "https://my-rpc.com",
programId: "FnBDGeXKx3CsrFqxfKrLMsuNeUmMZPP19DbLbmqj8wCZ",
apiUrl: "https://api.pompafly.fun",
wsUrl: "wss://api.pompafly.fun/ws",
};License
MIT
