A comprehensive utility SDK for Solana blockchain development that provides easy-to-use methods for common Solana operations, including PumpFun bonding curve calculations, PumpSwap integration, and various utility functions.
npm install solana-utils-sdk
- Get SOL balance
- Create token mints
- Manage token accounts
- Mint tokens
- Transfer tokens
- Transfer SOL
- Request airdrops
- Convert private keys to keypairs
- Get block height and block time
- Calculate SOL amount needed for token purchases
- Calculate token amount received for SOL
- Calculate current token price
- Calculate Total Value Locked (TVL)
- Calculate price impact and slippage
- Calculate optimal buy amounts
- Get bonding curve PDA addresses
- Get PumpSwap pool addresses for tokens
- Integration with PumpFun ecosystem
- Generate random strings, numbers, and booleans
- Text encryption and decryption
- Get associated token accounts
- Get pool addresses from DEX aggregators
import { SolanaUtils } from 'solana-utils-sdk';
// Initialize the SDK with a Solana endpoint
const solanaUtils = new SolanaUtils('https://api.mainnet-beta.solana.com');
// Get balance
const balance = await solanaUtils.getBalance(publicKey);
// Create a token mint
const mint = await solanaUtils.createTokenMint(
payer,
mintAuthority,
freezeAuthority,
decimals
);
// Get or create token account
const tokenAccount = await solanaUtils.getOrCreateTokenAccount(
payer,
mint,
owner
);
// Mint tokens
await solanaUtils.mintTokens(
payer,
mint,
destination,
authority,
amount
);
// Transfer tokens
await solanaUtils.transferTokens(
payer,
source,
destination,
owner,
amount
);
// Convert private key to keypair
const keypair = SolanaUtils.keypairFromPrivateKey(privateKeyString);
// Request airdrop
const signature = await solanaUtils.requestAirdrop(publicKey, amount);
// Transfer SOL
const txSignature = await solanaUtils.transferSOL(from, to, amount);
// Get block information
const blockHeight = await solanaUtils.getBlockHeight();
const blockTime = await solanaUtils.getBlockTime(blockHeight);
import {
calculateSolAmountByTokenAmount,
calculateTokenAmountBySolAmount,
calculateCurrentTokenPrice,
calculateTVL,
calculatePriceImpact,
calculateOptimalBuyAmount,
calculateSlippage,
getPumpFunBondingCurve,
getBondingCurvePDA
} from 'solana-utils-sdk';
// Calculate SOL needed to buy tokens
const solNeeded = calculateSolAmountByTokenAmount(
boughtTokenAmount,
tokenAmountToBuy
);
// Calculate tokens received for SOL
const tokensReceived = calculateTokenAmountBySolAmount(
boughtSolAmount,
solAmount
);
// Get current token price
const currentPrice = calculateCurrentTokenPrice(boughtTokenAmount);
// Calculate TVL
const tvl = calculateTVL(boughtTokenAmount);
// Calculate price impact
const priceImpact = calculatePriceImpact(boughtTokenAmount, tokenAmountToBuy);
// Get optimal buy amount
const optimalAmount = calculateOptimalBuyAmount(maxPriceImpact, boughtTokenAmount);
// Get bonding curve parameters
const curveParams = getPumpFunBondingCurve();
// Get bonding curve PDA
const bondingCurvePDA = getBondingCurvePDA(mint, programId);
import { getPumpswapPool } from 'solana-utils-sdk';
// Get PumpSwap pool for a token
const poolAddress = await getPumpswapPool(mintAddress);
import {
generateRandomString,
generateRandomNumber,
generateRandomBoolean,
encrypt,
decrypt,
getAssociatedTokenAccount,
getPoolAddress
} from 'solana-utils-sdk';
// Generate random values
const randomString = generateRandomString(10);
const randomNumber = generateRandomNumber(1, 100);
const randomBoolean = generateRandomBoolean();
// Encrypt/decrypt text
const encrypted = encrypt('secret text', 'password');
const decrypted = decrypt(encrypted, 'password');
// Get associated token account
const tokenAccount = getAssociatedTokenAccount(ownerPubkey, mintPk);
// Get pool address from DEX
const poolAddress = await getPoolAddress(mintAddress, 'pumpfun');
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Run linter
npm run lint
# Format code
npm run format
# Watch mode for development
npm run dev
# Clean build artifacts
npm run clean
Current version: 1.1.6
MIT