### Run Example Scripts Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Commands to install dependencies and execute example scripts from the repository. ```bash # Run any example cd examples npm install @solana/web3.js bs58 ws dotenv node buy-sell.js ``` -------------------------------- ### Run Example Scripts Source: https://github.com/pumpdev3/pumpdev.io/blob/main/examples/README.md Execute the provided example scripts using Node.js. ```bash node buy-sell.js node websocket.js node create-token.js ``` -------------------------------- ### Install Dependencies Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Install required Solana libraries for client-side operations. ```bash npm install @solana/web3.js bs58 ``` -------------------------------- ### Install Dependencies Source: https://github.com/pumpdev3/pumpdev.io/blob/main/examples/README.md Install the required Solana and utility packages for the PumpDev API. ```bash npm install @solana/web3.js bs58 ws dotenv ``` -------------------------------- ### Subscribe to New Token Launches via WebSocket Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Connect to the real-time WebSocket to receive instant notifications of new token launches on pump.fun. This example demonstrates subscribing to the 'subscribeNewToken' method and handling incoming messages. ```javascript import WebSocket from 'ws'; const ws = new WebSocket('wss://pumpdev.io/ws'); ws.on('open', () => { console.log('Connected to WebSocket'); // Subscribe to new token launches ws.send(JSON.stringify({ method: 'subscribeNewToken' })); }); ws.on('message', (data) => { const event = JSON.parse(data.toString()); if (event.type === 'subscribed') { console.log('Subscribed to:', event.method); return; } if (event.txType === 'create') { console.log(`NEW TOKEN: ${event.name} (${event.symbol})`); console.log(` Mint: ${event.mint}`); console.log(` Creator: ${event.traderPublicKey}`); console.log(` Initial Buy: ${event.solAmount} SOL`); console.log(` Market Cap: ${event.marketCapSol?.toFixed(2)} SOL`); console.log(` Link: https://pump.fun/${event.mint}`); } }); // Unsubscribe when done // ws.send(JSON.stringify({ method: 'unsubscribeNewToken' })); ``` -------------------------------- ### Create a Token Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Launches a new token with metadata stored locally for speed. Includes options for initial buy amounts and slippage. ```javascript const response = await fetch('https://pumpdev.io/api/create-lightning?api-key=YOUR_API_KEY', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: 'My Token', symbol: 'MTK', image: 'https://example.com/logo.png', description: 'My awesome token description', twitter: 'https://x.com/mytoken', telegram: 'https://t.me/mytoken', website: 'https://mytoken.com', buyAmountSol: 0.5, slippage: 30 }) }); const { mint, signature, metadataUri, pumpfun } = await response.json(); // Response: // { // "mint": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", // "signature": "5UfDuX...", // "metadataUri": "https://pumpdev.io/metadata/...", // "pumpfun": "https://pump.fun/7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU" // } ``` -------------------------------- ### Create Token with Initial Dev Buy Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Creates a new token and executes an initial buy transaction in one step. Requires a valid IPFS metadata URI. ```javascript import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const creator = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const metadataUri = await uploadMetadata(); // From IPFS upload const response = await fetch('https://pumpdev.io/api/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: creator.publicKey.toBase58(), name: 'My Token', symbol: 'MTK', uri: metadataUri, buyAmountSol: 0.5, slippage: 30 // cashbackEnabled: true // Optional: enable cashback for traders }) }); const result = await response.json(); const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey)); const tx = VersionedTransaction.deserialize(bs58.decode(result.transaction)); tx.sign([creator, mintKeypair]); const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const signature = await connection.sendRawTransaction(tx.serialize(), { skipPreflight: true, maxRetries: 3 }); console.log(`Token: https://pump.fun/${result.mint}`); console.log(`Transaction: https://solscan.io/tx/${signature}`); ``` -------------------------------- ### POST /api/create-lightning Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Launches a new token on pump.fun with one HTTP call. ```APIDOC ## POST /api/create-lightning ### Description Creates and launches a new token on pump.fun. ### Method POST ### Endpoint /api/create-lightning ### Query Parameters - **api-key** (string) - Required - The API key for authentication. ### Request Body - **name** (string) - Required - Name of the token. - **symbol** (string) - Required - Symbol of the token. - **image** (string) - Required - URL to the token image. - **buyAmountSol** (number) - Required - Initial buy amount in SOL. ### Response #### Success Response (200) - **mint** (string) - The new token mint address. - **signature** (string) - Transaction signature. - **pumpfun** (string) - URL to the token on pump.fun. ``` -------------------------------- ### Create a Lightning Wallet Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Initializes a new wallet for use with the Lightning API. ```javascript const res = await fetch('https://pumpdev.io/api/wallet/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ label: 'my-bot' }) }); const { apiKey, publicKey, privateKey } = await res.json(); ``` -------------------------------- ### POST /api/wallet/create Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Creates a new Lightning wallet for trading. ```APIDOC ## POST /api/wallet/create ### Description Creates a new wallet to be used with the Lightning API. ### Method POST ### Endpoint /api/wallet/create ### Request Body - **label** (string) - Required - A label for the new wallet. ### Response #### Success Response (200) - **apiKey** (string) - The API key for the wallet. - **publicKey** (string) - The public address of the wallet. - **privateKey** (string) - The private key of the wallet. ``` -------------------------------- ### Create Token with Dev Buy Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Creates a new token and executes an initial buy transaction in a single step. Requires a valid metadata URI from the upload process. ```javascript import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const API_URL = 'https://pumpdev.io'; async function createToken() { const creator = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const response = await fetch(`${API_URL}/api/create`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: creator.publicKey.toBase58(), name: 'PUMP FUN API', symbol: 'pumpdev.io', uri: metadataUri, // From Step 1 buyAmountSol: 0.1, // Dev buy amount in SOL slippage: 30, // Slippage % for buy (default: 30) // mintKeypair: 'OPTIONAL_MINT_SECRET_KEY_BASE58', // Optional: custom mint keypair }) }); const result = await response.json(); const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey)); // Sign transaction (create + dev buy in single tx) const tx = VersionedTransaction.deserialize(bs58.decode(result.transaction)); tx.sign([creator, mintKeypair]); // Send transaction const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const signature = await connection.sendTransaction(tx); console.log(`✅ Token: https://pump.fun/${result.mint}`); console.log(`Transaction: https://solscan.io/tx/${signature}`); } ``` -------------------------------- ### Create Token with Dev Buy (Jito Bundle) Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Use this snippet to create a token with a developer buy using Jito for faster transaction landing. The API returns separate transactions when jitoTip is provided. ```javascript import { VersionedTransaction, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const creator = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const response = await fetch('https://pumpdev.io/api/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: creator.publicKey.toBase58(), name: 'My Token', symbol: 'MTK', uri: 'ipfs://...', buyAmountSol: 0.5, slippage: 30, jitoTip: 0.01 // Adds Jito tip instruction }) }); const result = await response.json(); const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey)); // Sign all transactions const signedTxs = result.transactions.map((txInfo) => { const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction)); const signers = txInfo.signers.includes('mint') ? [creator, mintKeypair] : [creator]; tx.sign(signers); return bs58.encode(tx.serialize()); }); // Send via Jito const jitoResponse = await fetch('https://mainnet.block-engine.jito.wtf/api/v1/bundles', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'sendBundle', params: [signedTxs] }) }); const { result: bundleId } = await jitoResponse.json(); console.log(`Bundle: https://explorer.jito.wtf/bundle/${bundleId}`); console.log(`Token: https://pump.fun/${result.mint}`); ``` -------------------------------- ### Multi-Buyer Bundle Launch Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Create a token with multiple wallets buying atomically in the same block via Jito bundle. This ensures all buys happen together or not at all. ```javascript import { VersionedTransaction, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const creator = Keypair.fromSecretKey(bs58.decode('CREATOR_KEY')); const buyer1 = Keypair.fromSecretKey(bs58.decode('BUYER1_KEY')); const buyer2 = Keypair.fromSecretKey(bs58.decode('BUYER2_KEY')); const buyer3 = Keypair.fromSecretKey(bs58.decode('BUYER3_KEY')); const wallets = { creator, buyer1, buyer2, buyer3 }; const response = await fetch('https://pumpdev.io/api/create-bundle', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: creator.publicKey.toBase58(), name: 'My Token', symbol: 'MTK', uri: 'ipfs://...', buyAmountSol: 0.5, // Creator dev buy slippage: 30, jitoTip: 0.02, additionalBuyers: [ { publicKey: buyer1.publicKey.toBase58(), amountSol: 1.0 }, { publicKey: buyer2.publicKey.toBase58(), amountSol: 0.5 }, { publicKey: buyer3.publicKey.toBase58(), amountSol: 0.3 } ] }) }); const result = await response.json(); const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey)); const signedTxs = result.transactions.map((txInfo) => { const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction)); const signers = txInfo.signers .map(s => s === 'mint' ? mintKeypair : wallets[s]) .filter(Boolean); tx.sign(signers); return bs58.encode(tx.serialize()); }); // Send via Jito await fetch('https://mainnet.block-engine.jito.wtf/api/v1/bundles', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'sendBundle', params: [signedTxs] }) }); console.log(`Token: https://pump.fun/${result.mint}`); ``` -------------------------------- ### Create a Cashback-Enabled Token Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Initiates the creation of a new token with the cashback feature enabled. Requires creator's public key, token details, and metadata URI. ```javascript const response = await fetch(`${API_URL}/api/create`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: creator.publicKey.toBase58(), name: 'My Token', symbol: 'MTK', uri: metadataUri, cashbackEnabled: true, // Enable cashback for traders buyAmountSol: 0.5, slippage: 30 }) }); ``` -------------------------------- ### Claim Fees with Fee Sharing Source: https://github.com/pumpdev3/pumpdev.io/blob/main/examples/README.md Execute the claim-fees script with or without the MINT environment variable to handle standard or fee-sharing claims. ```bash # Standard claim (no fee sharing) PRIVATE_KEY=YourKey node claim-fees.js # Fee sharing claim (rewards split to multiple addresses) PRIVATE_KEY=YourKey MINT=TokenMintAddress node claim-fees.js ``` -------------------------------- ### Create Token with Dev Buy (Bundle) Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Use this function to create a new token and automatically perform a developer buy as part of a Jito bundle. Ensure you have your private key correctly formatted. ```javascript import { VersionedTransaction, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const API_URL = 'https://pumpdev.io'; async function createTokenWithDevBuy() { const creator = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const response = await fetch(`${API_URL}/api/create`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: creator.publicKey.toBase58(), name: 'PUMP FUN API', symbol: 'pumpdev.io', uri: 'https://ipfs.io/ipfs/...', buyAmountSol: 0.5, // Dev buy amount slippage: 30, jitoTip: 0.01 }) }); const result = await response.json(); const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey)); // Sign all transactions (create + dev buy) const signedTxs = result.transactions.map((txInfo) => { const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction)); const signers = txInfo.signers.includes('mint') ? [creator, mintKeypair] : [creator]; tx.sign(signers); return bs58.encode(tx.serialize()); }); // Send via Jito bundle await fetch('https://mainnet.block-engine.jito.wtf/api/v1/bundles', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'sendBundle', params: [signedTxs] }) }); console.log(`✅ Token: https://pump.fun/${result.mint}`); } ``` -------------------------------- ### Execute Fast Bundle Sell Transactions Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Build and execute sell transactions for multiple wallets simultaneously to improve performance. Requires pre-signed transactions and valid keypairs for each account. ```javascript import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const accounts = [ { name: 'creator', keypair: Keypair.fromSecretKey(bs58.decode('...')) }, { name: 'bundle1', keypair: Keypair.fromSecretKey(bs58.decode('...')) }, { name: 'bundle2', keypair: Keypair.fromSecretKey(bs58.decode('...')) } ]; const response = await fetch('https://pumpdev.io/api/trade-bundle', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ accounts: accounts.map(acc => ({ publicKey: acc.keypair.publicKey.toBase58(), name: acc.name })), action: 'sell', mint: 'TokenMintAddress', amount: '100%', denominatedInSol: 'false', slippage: 99, priorityFee: 0.005, creator: accounts[0].keypair.publicKey.toBase58() // Skip bonding curve lookup }) }); const result = await response.json(); // Response: { transactions: [...], stats: { total: 3, success: 2, failed: 1, durationMs: 150 } } const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); for (const txInfo of result.transactions) { if (!txInfo.transaction) continue; const account = accounts.find(a => a.name === txInfo.name); const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction)); tx.sign([account.keypair]); const signature = await connection.sendTransaction(tx, { skipPreflight: true }); console.log(`${txInfo.name} sent: ${signature}`); } ``` -------------------------------- ### Create Token with Multiple Buyers (Bundle) Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md This function creates a token and allows multiple wallets to buy into it atomically within a single Jito bundle. It's useful for launching tokens with pre-committed buyers. ```javascript async function createMultiBuyerBundle() { const creator = Keypair.fromSecretKey(bs58.decode('CREATOR_KEY')); const buyer1 = Keypair.fromSecretKey(bs58.decode('BUYER1_KEY')); const buyer2 = Keypair.fromSecretKey(bs58.decode('BUYER2_KEY')); const response = await fetch(`${API_URL}/api/create-bundle`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: creator.publicKey.toBase58(), name: 'PUMP FUN API', symbol: 'pumpdev.io', uri: 'https://ipfs.io/ipfs/...', buyAmountSol: 0.5, // Creator dev buy slippage: 30, jitoTip: 0.01, additionalBuyers: [ { publicKey: buyer1.publicKey.toBase58(), amountSol: 1.0 }, { publicKey: buyer2.publicKey.toBase58(), amountSol: 0.5 } ] }) }); const result = await response.json(); const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey)); const wallets = { creator, buyer1, buyer2 }; // Sign each transaction with appropriate signers const signedTxs = result.transactions.map((txInfo) => { const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction)); const signers = txInfo.signers.map(s => s === 'mint' ? mintKeypair : wallets[s]).filter(Boolean); tx.sign(signers); return bs58.encode(tx.serialize()); }); // Send Jito bundle await fetch('https://mainnet.block-engine.jito.wtf/api/v1/bundles', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'sendBundle', params: [signedTxs] }) }); console.log(`✅ Token: https://pump.fun/${result.mint}`); } ``` -------------------------------- ### Execute Client-Side Buy Transaction Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Builds and signs a buy transaction locally using the Solana web3.js library. Requires a private key and the target token mint address. ```javascript import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const keypair = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const response = await fetch('https://pumpdev.io/api/trade-local', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: keypair.publicKey.toBase58(), action: 'buy', mint: 'TokenMintAddress', amount: 0.1, denominatedInSol: 'true', slippage: 15, priorityFee: 0.001 }) }); const data = await response.arrayBuffer(); const tx = VersionedTransaction.deserialize(new Uint8Array(data)); tx.sign([keypair]); const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const signature = await connection.sendTransaction(tx, { skipPreflight: false, maxRetries: 3 }); console.log('Transaction:', `https://solscan.io/tx/${signature}`); ``` -------------------------------- ### Create a Lightning Wallet Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Generates a new Solana keypair and returns an API key for server-side signing. The private key must be stored securely as it cannot be recovered. ```javascript const response = await fetch('https://pumpdev.io/api/wallet/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ label: 'my-trading-bot' }) }); const { apiKey, publicKey, privateKey } = await response.json(); // Response: // { // "apiKey": "pk_live_abc123...", // "publicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", // "privateKey": "5MaiiCavjCmn9Hs1o3eznqDEhRwxo7pXiAYez7keQUviUkauRiTMD8DrESdrNjN8zd9mTmVhRvBJeg5vhyvgrAhG", // "warning": "Save your private key securely - it cannot be recovered!" // } ``` -------------------------------- ### Buy Tokens on Pump.fun Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Executes a buy order for a specific token mint. Requires the user's private key and the target mint address. ```javascript async function buyToken(privateKey, mint, amountSol) { const keypair = Keypair.fromSecretKey(bs58.decode(privateKey)); const response = await fetch(`${API_URL}/api/trade-local`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: keypair.publicKey.toBase58(), action: 'buy', mint: mint, amount: amountSol, slippage: 99, }) }); const data = await response.arrayBuffer(); const tx = VersionedTransaction.deserialize(new Uint8Array(data)); tx.sign([keypair]); const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const signature = await connection.sendTransaction(tx); console.log('Transaction:', `https://solscan.io/tx/${signature}`); } ``` -------------------------------- ### Claim Cashback Rewards Source: https://github.com/pumpdev3/pumpdev.io/blob/main/examples/README.md Run the claim-fees script to process cashback rewards. ```bash PRIVATE_KEY=YourKey node claim-fees.js # Uncomment the claimCashback() call in main() to claim cashback ``` -------------------------------- ### Create Tokens via Lightning API Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Launches a new token on pump.fun with metadata stored locally by PumpDev. ```javascript const res = await fetch('https://pumpdev.io/api/create-lightning?api-key=YOUR_KEY', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: 'My Token', symbol: 'MTK', image: 'https://example.com/logo.png', buyAmountSol: 0.5 }) }); const { mint, signature, pumpfun } = await res.json(); console.log('Token launched!', pumpfun); ``` -------------------------------- ### Import a Lightning Wallet Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Imports an existing Solana wallet for use with the Lightning API, returning an API key without exposing the private key. ```javascript const response = await fetch('https://pumpdev.io/api/wallet/import', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ privateKey: 'YOUR_BASE58_PRIVATE_KEY' }) }); const { apiKey, publicKey } = await response.json(); // Response: // { // "apiKey": "pk_live_xyz789...", // "publicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU" // } ``` -------------------------------- ### Lightning Wallet Creation API Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Creates a new Lightning wallet for server-side signing. The API generates a new Solana keypair and returns an API key for authenticated requests. The private key must be saved securely as it cannot be recovered. ```APIDOC ## POST /api/wallet/create ### Description Create a new Lightning wallet for server-side signing. The API generates a new Solana keypair and returns an API key for authenticated requests. Save the private key securely as it cannot be recovered. ### Method POST ### Endpoint /api/wallet/create ### Parameters #### Request Body - **label** (string) - Required - A label for the wallet. ### Request Example ```json { "label": "my-trading-bot" } ``` ### Response #### Success Response (200) - **apiKey** (string) - The API key for authenticated requests. - **publicKey** (string) - The public key of the newly created wallet. - **privateKey** (string) - The private key of the newly created wallet. **Must be saved securely.** - **warning** (string) - A warning message about saving the private key. #### Response Example ```json { "apiKey": "pk_live_abc123...", "publicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", "privateKey": "5MaiiCavjCmn9Hs1o3eznqDEhRwxo7pXiAYez7keQUviUkauRiTMD8DrESdrNjN8zd9mTmVhRvBJeg5vhyvgrAhG", "warning": "Save your private key securely - it cannot be recovered!" } ``` ``` -------------------------------- ### Implement a Sniper Bot Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Automate token purchases by listening for new token creation events and executing trades based on predefined criteria. ```javascript import WebSocket from 'ws'; import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const keypair = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const SETTINGS = { buyAmountSol: 0.01, slippage: 20, maxMarketCapSol: 50, minInitialBuySol: 0.5, cooldownMs: 5000 }; let lastBuyTime = 0; const ws = new WebSocket('wss://pumpdev.io/ws'); ws.on('open', () => { ws.send(JSON.stringify({ method: 'subscribeNewToken' })); }); ws.on('message', async (data) => { const event = JSON.parse(data.toString()); if (event.txType !== 'create') return; // Check criteria if (event.marketCapSol > SETTINGS.maxMarketCapSol) return; if (event.solAmount < SETTINGS.minInitialBuySol) return; if (Date.now() - lastBuyTime < SETTINGS.cooldownMs) return; console.log(`Sniping: ${event.name} (${event.symbol})`); const response = await fetch('https://pumpdev.io/api/trade-local', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: keypair.publicKey.toBase58(), action: 'buy', mint: event.mint, amount: SETTINGS.buyAmountSol, denominatedInSol: 'true', slippage: SETTINGS.slippage }) }); const txData = await response.arrayBuffer(); const tx = VersionedTransaction.deserialize(new Uint8Array(txData)); tx.sign([keypair]); const signature = await connection.sendTransaction(tx, { skipPreflight: true }); console.log(`Bought: ${signature}`); lastBuyTime = Date.now(); }); ``` -------------------------------- ### Connect to PumpDev WebSocket Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Establishes a connection to the WebSocket server to subscribe to token launches, specific token trades, and whale wallet activity. ```javascript import WebSocket from 'ws'; const ws = new WebSocket('wss://pumpdev.io/ws'); ws.on('open', () => { // Subscribe to new pump.fun token launches ws.send(JSON.stringify({ method: 'subscribeNewToken' })); // Subscribe to specific token trades ws.send(JSON.stringify({ method: 'subscribeTokenTrade', keys: ['TokenMint1', 'TokenMint2'] })); // Track whale wallets ws.send(JSON.stringify({ method: 'subscribeAccountTrade', keys: ['WhaleWallet1', 'WhaleWallet2'] })); }); ws.on('message', (data) => { const event = JSON.parse(data.toString()); if (event.txType === 'create') { console.log(`🆕 New Token: ${event.name} (${event.symbol})`); console.log(` Mint: ${event.mint}`); console.log(` Market Cap: ${event.marketCapSol} SOL`); } if (event.txType === 'buy' || event.txType === 'sell') { console.log(`📊 ${event.txType.toUpperCase()}: ${event.solAmount} SOL`); } }); ``` -------------------------------- ### Build and Execute Fast Bundle Sell Transaction Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Builds all necessary transactions in a single API call and then signs and sends them. Ensure all required accounts and their keypairs are correctly provided. ```javascript import { VersionedTransaction, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const API_URL = 'https://pumpdev.io'; async function sellBundleFast(mint, accounts, creatorPublicKey) { // 1. Build ALL transactions in ONE API call const response = await fetch(`${API_URL}/api/trade-bundle`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ accounts: accounts.map(acc => ({ publicKey: acc.keypair.publicKey.toBase58(), name: acc.name, })), action: 'sell', mint: mint, amount: '100%', slippage: 99, priorityFee: 0.005, creator: creatorPublicKey, // SPEED: skip bonding curve lookup }), }); const result = await response.json(); console.log(`Built ${result.stats.success}/${result.stats.total} in ${result.stats.durationMs}ms`); // 2. Sign and send each transaction for (const txInfo of result.transactions) { if (!txInfo.transaction) continue; const account = accounts.find(a => a.name === txInfo.name); const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction)); tx.sign([account.keypair]); const signature = await connection.sendTransaction(tx, { skipPreflight: true }); console.log(`${txInfo.name} sent: ${signature}`); } } // Usage const accounts = [ { name: 'creator', keypair: Keypair.fromSecretKey(bs58.decode('...')) }, { name: 'bundle1', keypair: Keypair.fromSecretKey(bs58.decode('...')) }, { name: 'bundle2', keypair: Keypair.fromSecretKey(bs58.decode('...')) }, ]; await sellBundleFast('TokenMint', accounts, accounts[0].keypair.publicKey.toBase58()); ``` -------------------------------- ### Execute Client-Side Sell Transaction Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Builds and signs a sell transaction locally. Supports percentage-based amounts like '100%' or exact token quantities. ```javascript import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const keypair = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const response = await fetch('https://pumpdev.io/api/trade-local', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: keypair.publicKey.toBase58(), action: 'sell', mint: 'TokenMintAddress', amount: '100%', // Supports: '100%', '50%', '25%', or exact amount denominatedInSol: 'false', slippage: 15 }) }); const data = await response.arrayBuffer(); const tx = VersionedTransaction.deserialize(new Uint8Array(data)); tx.sign([keypair]); const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const signature = await connection.sendTransaction(tx); console.log('Sold:', signature); ``` -------------------------------- ### Sell Tokens on Pump.fun Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Executes a sell order for a specific token mint. Supports percentage-based selling or exact amounts. ```javascript // Sell 100% of tokens const response = await fetch(`${API_URL}/api/trade-local`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: 'YourPublicKey', action: 'sell', mint: 'TokenMintAddress', amount: '100%', // Supports: '100%', '50%', or exact amount slippage: 99 }) }); const data = await response.arrayBuffer(); const tx = VersionedTransaction.deserialize(new Uint8Array(data)); tx.sign([keypair]); const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const signature = await connection.sendTransaction(tx); console.log('Transaction:', `https://solscan.io/tx/${signature}`); ``` -------------------------------- ### Lightning Wallet Import API Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Imports an existing Solana wallet to use with the Lightning API. Returns an API key for the imported wallet without exposing the private key in responses. ```APIDOC ## POST /api/wallet/import ### Description Import an existing Solana wallet to use with Lightning API. Returns an API key for the imported wallet without exposing the private key in responses. ### Method POST ### Endpoint /api/wallet/import ### Parameters #### Request Body - **privateKey** (string) - Required - The base58 encoded private key of the Solana wallet. ### Request Example ```json { "privateKey": "YOUR_BASE58_PRIVATE_KEY" } ``` ### Response #### Success Response (200) - **apiKey** (string) - The API key for authenticated requests. - **publicKey** (string) - The public key of the imported wallet. #### Response Example ```json { "apiKey": "pk_live_xyz789...", "publicKey": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU" } ``` ``` -------------------------------- ### Subscribe to Token Trades via WebSocket Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Connect to the WebSocket stream to monitor buy and sell events for specific token mints in real-time. ```javascript import WebSocket from 'ws'; const ws = new WebSocket('wss://pumpdev.io/ws'); ws.on('open', () => { // Subscribe to specific token trades ws.send(JSON.stringify({ method: 'subscribeTokenTrade', keys: ['TokenMint1', 'TokenMint2'] })); }); ws.on('message', (data) => { const event = JSON.parse(data.toString()); if (event.txType === 'buy') { console.log(`BUY: +${event.solAmount} SOL | ${event.tokenAmount} tokens`); console.log(` Trader: ${event.traderPublicKey}`); console.log(` Market Cap: ${event.marketCapSol?.toFixed(2)} SOL`); } if (event.txType === 'sell') { console.log(`SELL: -${event.solAmount} SOL | ${event.tokenAmount} tokens`); console.log(` Trader: ${event.traderPublicKey}`); console.log(` Market Cap: ${event.marketCapSol?.toFixed(2)} SOL`); } }); // Unsubscribe // ws.send(JSON.stringify({ method: 'unsubscribeTokenTrade', keys: ['TokenMint1'] })); ``` -------------------------------- ### POST /api/trade-lightning Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Executes a buy or sell trade on pump.fun using the Lightning API. ```APIDOC ## POST /api/trade-lightning ### Description Executes a buy or sell action for a specific token mint. ### Method POST ### Endpoint /api/trade-lightning ### Query Parameters - **api-key** (string) - Required - The API key for authentication. ### Request Body - **action** (string) - Required - 'buy' or 'sell'. - **mint** (string) - Required - The token mint address. - **amount** (number/string) - Required - Amount to trade or '100%' for selling. - **denominatedInSol** (string) - Required - 'true' or 'false'. - **slippage** (number) - Required - Slippage tolerance. ### Response #### Success Response (200) - **signature** (string) - Transaction signature. - **solscan** (string) - URL to the transaction on Solscan. ``` -------------------------------- ### Lightning Token Creation API Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Creates tokens instantly with a single HTTP call. PumpDev stores metadata locally for fastest launches without IPFS roundtrip delays. ```APIDOC ## POST /api/create-lightning ### Description Create tokens instantly with one HTTP call. PumpDev stores metadata locally for fastest launches without IPFS roundtrip delays. ### Method POST ### Endpoint /api/create-lightning ### Parameters #### Query Parameters - **api-key** (string) - Required - Your PumpDev API key. #### Request Body - **name** (string) - Required - The name of the token. - **symbol** (string) - Required - The symbol of the token. - **image** (string) - Required - URL of the token's image. - **description** (string) - Optional - Description of the token. - **twitter** (string) - Optional - URL to the token's Twitter profile. - **telegram** (string) - Optional - URL to the token's Telegram group. - **website** (string) - Optional - URL to the token's website. - **buyAmountSol** (number) - Required - The amount of SOL to use for the initial buy. - **slippage** (number) - Optional - The maximum acceptable slippage percentage for the initial buy (e.g., 30 for 30%). ### Request Example ```json { "name": "My Token", "symbol": "MTK", "image": "https://example.com/logo.png", "description": "My awesome token description", "twitter": "https://x.com/mytoken", "telegram": "https://t.me/mytoken", "website": "https://mytoken.com", "buyAmountSol": 0.5, "slippage": 30 } ``` ### Response #### Success Response (200) - **mint** (string) - The mint address of the newly created token. - **signature** (string) - The transaction signature for token creation. - **metadataUri** (string) - The URI where the token's metadata is stored. - **pumpfun** (string) - A URL to the token's page on pump.fun. #### Response Example ```json { "mint": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU", "signature": "5UfDuX...", "metadataUri": "https://pumpdev.io/metadata/...", "pumpfun": "https://pump.fun/7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU" } ``` ``` -------------------------------- ### Track Wallet Activity via WebSocket Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Monitor specific wallet addresses for trading activity, useful for whale tracking or competitor analysis. ```javascript import WebSocket from 'ws'; const ws = new WebSocket('wss://pumpdev.io/ws'); ws.on('open', () => { // Track specific wallets ws.send(JSON.stringify({ method: 'subscribeAccountTrade', keys: ['WhaleWallet1', 'WhaleWallet2'] })); }); ws.on('message', (data) => { const event = JSON.parse(data.toString()); if (event.txType === 'buy' || event.txType === 'sell') { console.log(`${event.txType.toUpperCase()} by ${event.traderPublicKey.slice(0, 8)}...`); console.log(` Token: ${event.mint}`); console.log(` Amount: ${event.solAmount} SOL`); } }); // Unsubscribe // ws.send(JSON.stringify({ method: 'unsubscribeAccountTrade', keys: ['WhaleWallet1'] })); ``` -------------------------------- ### Execute Lightning Trades Source: https://github.com/pumpdev3/pumpdev.io/blob/main/README.md Perform buy and sell operations using the Lightning API. Requires an API key and the target token mint address. ```javascript // Buy token — one call, server signs + sends const res = await fetch('https://pumpdev.io/api/trade-lightning?api-key=YOUR_KEY', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'buy', mint: 'TokenMintAddress', amount: 0.1, denominatedInSol: 'true', slippage: 15 }) }); const { signature, solscan } = await res.json(); console.log('Done!', solscan); ``` ```javascript // Sell 100% of tokens — one call const res = await fetch('https://pumpdev.io/api/trade-lightning?api-key=YOUR_KEY', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'sell', mint: 'TokenMintAddress', amount: '100%', denominatedInSol: 'false', slippage: 15 }) }); const { signature, solscan } = await res.json(); console.log('Sold!', solscan); ``` -------------------------------- ### Distribute Creator Fees Source: https://context7.com/pumpdev3/pumpdev.io/llms.txt Trigger a permissionless distribution of accumulated fees to all shareholders. Requires the specific mint address to identify the distribution pool. ```javascript import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js'; import bs58 from 'bs58'; const keypair = Keypair.fromSecretKey(bs58.decode('YOUR_PRIVATE_KEY')); const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed'); const response = await fetch('https://pumpdev.io/api/claim-distribute', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ publicKey: keypair.publicKey.toBase58(), mint: 'TokenMintAddress' // Required for distribution }) }); const data = await response.arrayBuffer(); const tx = VersionedTransaction.deserialize(new Uint8Array(data)); tx.sign([keypair]); const signature = await connection.sendTransaction(tx, { skipPreflight: false, maxRetries: 3 }); console.log('Fees distributed to all shareholders:', signature); ```