BSC PumpFun Documentation
Everything you need to deploy and run your own token launchpad on BNB Chain.
Overview
BSC PumpFun is a full-stack token launchpad on BNB Smart Chain. It lets anyone create a new BEP-20 token with a bonding curve, trade it instantly on-chain, and automatically graduate it to PancakeSwap when the fundraising hard cap is reached.
Key Features
- Fair launch — tokens are created with no pre-sale or team allocation. The entire supply is held by the launchpad contract and sold through the bonding curve.
- Bonding curve pricing — token price rises predictably as supply is purchased, giving early buyers a lower cost basis.
- Auto-graduation to PancakeSwap — once the hard cap is hit, the contract automatically pairs remaining tokens with raised BNB and adds liquidity on PancakeSwap. LP tokens are burned.
- Real-time updates — a WebSocket server pushes trades, price changes, and graduation events to all connected clients instantly.
- Admin panel — flag or unflag tokens, view platform stats, and manage graduation from a built-in admin dashboard.
- Token comments — users can post comments on any token page for community discussion.
How It Works
1. Token Creation
A creator connects their wallet, fills in the token name, symbol, description, and uploads an image. They pay a creation fee (default 0.02 BNB) to the smart contract. The contract deploys a new BEP-20 token, mints the total supply to the launchpad contract, and initializes a bonding curve for the token.
2. Trading on the Bonding Curve
Anyone can buy or sell the token directly through the launchpad contract. When you buy, you send BNB and receive tokens. When you sell, you return tokens and receive BNB. The price is determined algorithmically by the bonding curve — it increases as more tokens are bought and decreases as they are sold.
3. Graduation to PancakeSwap
When the total BNB raised for a token reaches the hard cap (default 0.05 BNB for testnet), the token becomes eligible for graduation. The graduation process sends the remaining unsold tokens and the raised BNB to PancakeSwap Router via addLiquidityETH, creating a trading pair. The LP tokens are permanently burned by sending them to a dead address.
Bonding Curve Explained
The launchpad uses a linear bonding curve. The price of a token is a function of how many tokens have been sold:
price(x) = basePrice + slope * x / TOKEN_SCALE where: x = number of tokens sold so far (in wei, 18 decimals) basePrice = starting price (in wei) slope = price increase per full token sold (in wei) TOKEN_SCALE = 1e18
The cost to buy a batch of tokens and the proceeds from selling are calculated as integrals of this price function. This ensures smooth, continuous pricing with no slippage gaps.
Default Parameters
basePrice= 1 wei — the starting price per tokenslope= 1 — controls how steeply the price risesmaxSupply= 1,000,000,000 tokens (1 billion)creationFee= 0.02 BNB — paid on token creationhardCap= 0.05 BNB — graduation threshold (testnet default)
Changing Parameters
The creationFee and hardCap are set as constructor arguments when deploying the smart contract. To change them, update the values in contracts/scripts/deploy.ts and redeploy. Token-level parameters like basePrice, slope, and maxSupply are set during token creation and can be adjusted in the create token page at src/app/create/page.tsx.
Graduation & PancakeSwap
What Triggers Graduation
Graduation is triggered when the total BNB raised for a token meets or exceeds the hardCap set in the contract. This can happen automatically via the cron graduation endpoint or be triggered manually from the admin panel.
What Happens During Graduation
- The contract calls PancakeSwap Router's
addLiquidityETHfunction. - Remaining unsold tokens and the raised BNB are paired as liquidity.
- The LP tokens received are burned by sending them to
0x000...dEaD, permanently locking the liquidity. - The token is marked as graduated in the database, and a
Graduatedevent is emitted on-chain.
Post-Graduation
After graduation, the token is no longer tradeable on the bonding curve. All trading happens on PancakeSwap. The token detail page automatically shows a link to PancakeSwap for trading graduated tokens.
Requirements
- Node.js 18+ — required for Next.js 16 and the WebSocket server
- PostgreSQL 14+ — used for storing tokens, trades, users, and comments
- npm or yarn — for package management
- MetaMask or any WalletConnect-compatible wallet — for connecting to the launchpad
- BNB — for gas fees and token creation fees
- BSC Testnet BNB (for testing) — available from the BNB Chain Faucet
Installation
1. Download & Extract
Download the BSC PumpFun ZIP file from web3.market and extract it to your desired directory.
2. Install Dependencies
Install the dependencies for both the main application and the smart contracts:
# Install app dependencies npm install # Install contract dependencies cd contracts npm install cd ..
3. Configure Environment
Copy the example environment file and fill in your values:
cp .env.example .env.local
See the Environment Variables section below for a full breakdown of each variable.
Environment Variables
All configuration is done through environment variables in .env.local. Variables prefixed with NEXT_PUBLIC_ are exposed to the browser; all others are server-only.
Database
DATABASE_URLserver-onlyPostgreSQL connection string.
Example: postgresql://pumpfun:secret@localhost:5433/bsc_pumpfun_launchpad
BSC Chain
NEXT_PUBLIC_BSC_CHAIN_IDpublicChain ID. Use 97 for BSC Testnet or 56 for BSC Mainnet.
Example: 97
NEXT_PUBLIC_BSC_RPC_URLpublicRPC endpoint for the BNB Smart Chain network.
Example: https://data-seed-prebsc-1-s1.binance.org:8545/
NEXT_PUBLIC_CONTRACT_ADDRESSpublicDeployed PumpLaunchpad contract address.
Example: 0x1234...abcd
Wallet Connection
NEXT_PUBLIC_WALLETCONNECT_PROJECT_IDpublicWalletConnect Cloud project ID. Get one free at cloud.walletconnect.com.
Example: abc123def456
Platform Settings
NEXT_PUBLIC_HARD_CAP_BNBpublicGraduation threshold in BNB. Must match the hardCap constructor arg of the deployed contract.
Example: 0.5
NEXT_PUBLIC_CREATION_FEE_BNBpublicToken creation fee in BNB. Must match the creationFee constructor arg of the deployed contract.
Example: 0.02
Admin
ADMIN_WALLETserver-onlyAdmin wallet address for server-side authorization checks.
Example: 0xYourAdminWalletAddress
NEXT_PUBLIC_ADMIN_WALLETpublicAdmin wallet address exposed to the client for UI visibility (e.g., showing admin controls).
Example: 0xYourAdminWalletAddress
DEPLOYER_PRIVATE_KEYserver-onlyPrivate key of the deployer wallet. Used for contract deployment and server-side graduation transactions.
Warning
DEPLOYER_PRIVATE_KEY to version control. Keep it in .env.local only and add that file to your .gitignore.IPFS / Pinata
PINATA_JWTserver-onlyPinata JWT token for uploading token images to IPFS.
NEXT_PUBLIC_PINATA_GATEWAYpublicPinata gateway domain for loading IPFS images.
Example: gateway.pinata.cloud
WebSocket Server
NEXT_PUBLIC_WS_URLpublicWebSocket server URL. Clients connect here for real-time updates.
Example: ws://localhost:3001
WS_PORTserver-onlyPort for the WebSocket server.
Example: 3001
WS_HTTP_PORTserver-onlyPort for the WebSocket HTTP broadcast endpoint (used internally by API routes).
Example: 3002
WS_HTTP_URLserver-onlyInternal URL for the HTTP broadcast endpoint.
Example: http://localhost:3002
PancakeSwap
NEXT_PUBLIC_PANCAKESWAP_ROUTERpublicPancakeSwap Router contract address. Differs between testnet and mainnet.
Example: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 (testnet)
NEXT_PUBLIC_PANCAKESWAP_FACTORYpublicPancakeSwap Factory contract address.
Example: 0x6725F303b657a9451d8BA641348b6761A6CC7a17 (testnet)
Application
NEXT_PUBLIC_APP_URLpublicBase URL of your application. Used for metadata and CORS.
Example: http://localhost:3000
Database Setup
Option A: Docker (recommended)
If you have Docker installed, the simplest way to run PostgreSQL:
docker run -d \ --name bsc-pumpfun-db \ -e POSTGRES_USER=pumpfun \ -e POSTGRES_PASSWORD=pumpfun_secret \ -e POSTGRES_DB=bsc_pumpfun_launchpad \ -p 5433:5432 \ postgres:16
Option B: Local PostgreSQL
Install PostgreSQL 14+ via your package manager and create a database manually. Update DATABASE_URL in .env.local with your connection string.
Create Tables
Once the database is running, push the Prisma schema to create all tables:
npx prisma db push
To explore the database with a visual GUI:
npx prisma studio
Smart Contract Deployment
1. Compile
cd contracts npx hardhat compile
2. Configure Deployer
Make sure DEPLOYER_PRIVATE_KEY is set in your .env.local file. This wallet needs BNB on the target network to pay for gas.
3. Deploy to BSC Testnet
npx hardhat run scripts/deploy.ts --network bscTestnet
The deploy script will output the contract address and environment variables. Copy the contract address to NEXT_PUBLIC_CONTRACT_ADDRESS in your .env.local.
4. Verify on BscScan (optional)
Verifying the contract source code on BscScan allows users to read the contract and builds trust:
npx hardhat verify --network bscTestnet <CONTRACT_ADDRESS> <CREATION_FEE_WEI> <HARD_CAP_WEI>
For the default values, the creation fee is 20000000000000000 (0.02 BNB in wei) and the hard cap is 50000000000000000 (0.05 BNB in wei).
5. Customize Contract Parameters
To change the creation fee or hard cap, edit contracts/scripts/deploy.ts:
const creationFee = ethers.parseEther("0.02"); // Change creation fee here
const hardCap = ethers.parseEther("0.05"); // Change hard cap hereRunning the Application
Development
Start the Next.js development server with Turbopack for fast refresh:
npm run dev
In a separate terminal, start the WebSocket server for real-time updates:
npm run ws
Open http://localhost:3000 in your browser.
Production
# Build the Next.js application npm run build # Start the production server npm start # Start the WebSocket server (separate process) npm run ws
Tip
pm2 to keep both the Next.js server and WebSocket server running in production.Switching to BSC Mainnet
To switch from testnet to mainnet, update the following environment variables in .env.local:
1. Chain Configuration
# Change chain ID from 97 (testnet) to 56 (mainnet) NEXT_PUBLIC_BSC_CHAIN_ID="56" # Change to a mainnet RPC URL NEXT_PUBLIC_BSC_RPC_URL="https://bsc-dataseed1.binance.org/"
2. Deploy Contract to Mainnet
cd contracts npx hardhat run scripts/deploy.ts --network bscMainnet
Update NEXT_PUBLIC_CONTRACT_ADDRESS with the new mainnet contract address.
3. PancakeSwap Addresses
Update the PancakeSwap contract addresses for mainnet:
# PancakeSwap V2 mainnet addresses NEXT_PUBLIC_PANCAKESWAP_ROUTER="0x10ED43C718714eb63d5aA57B78B54704E256024E" NEXT_PUBLIC_PANCAKESWAP_FACTORY="0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"
4. Adjust Parameters
For mainnet, you will likely want higher values for the creation fee and hard cap. Update them in contracts/scripts/deploy.ts before deploying, and update the matching environment variables:
NEXT_PUBLIC_HARD_CAP_BNB="10" NEXT_PUBLIC_CREATION_FEE_BNB="0.1"
Warning
Customization Guide
Theme & Colors
All theme colors are defined as CSS variables in src/app/globals.css. The app uses a dark theme by default with BSC-yellow accents. Key custom colors:
--color-bsc-yellow: #F0B90B; --color-bsc-gold: #FCD535; --color-pancake-cyan: #1FC7D4; --color-bnb-orange: #F3BA2F; --color-price-up: #00ff88; --color-price-down: #ff4444;
The .dark selector in the same file controls all background, foreground, card, and border colors using HSL values. Edit these to change the overall look.
Branding
- Logo: Replace
public/logo.svgwith your own SVG logo. - Site title & description: Edit the
metadataexport insrc/app/layout.tsx.
Bonding Curve Parameters
Contract-level parameters (creationFee, hardCap) are set in the deploy script. Token-level defaults (basePrice, slope, maxSupply) can be adjusted in the create token page at src/app/create/page.tsx.
Token Image Uploads
Token images are uploaded to IPFS via Pinata. Set PINATA_JWT with your Pinata API token and NEXT_PUBLIC_PINATA_GATEWAY with your gateway domain. The upload endpoint is at /api/upload.
Admin Wallets
Set the ADMIN_WALLET and NEXT_PUBLIC_ADMIN_WALLET environment variables to the wallet address that should have admin access. This wallet can flag tokens and access the admin panel.
WebSocket Port
Change WS_PORT to run the WebSocket server on a different port. Make sure NEXT_PUBLIC_WS_URL matches.
Admin Panel
The admin panel is accessible at /admin and requires that the connected wallet matches the ADMIN_WALLET address configured in your environment.
Features
- Flag / unflag tokens — flagged tokens are hidden from the homepage listing but remain accessible via direct URL.
- View all tokens — see every token including flagged ones, with sorting and filtering.
- Manage graduation — trigger graduation manually for tokens that have reached the hard cap.
API Reference
The launchpad exposes a REST API under /api. All responses are JSON.
Tokens
/api/tokensList tokens with pagination, filtering, and sorting. Query params: page, limit, search, sort, graduated.
/api/tokensCreate a new token record after on-chain creation.
/api/tokens/trendingGet trending tokens based on recent trading volume.
/api/tokens/[tokenAddress]Get details for a single token by its contract address.
/api/tokens/[tokenAddress]/tradesGet trade history for a token with pagination.
/api/tokens/[tokenAddress]/tradesRecord a new trade (buy or sell) for a token.
/api/tokens/[tokenAddress]/chartGet OHLCV candlestick chart data for a token.
/api/tokens/[tokenAddress]/holdersGet the list of token holders and their balances.
/api/tokens/[tokenAddress]/commentsGet comments posted on a token.
/api/tokens/[tokenAddress]/commentsPost a new comment on a token.
/api/tokens/[tokenAddress]/graduateTrigger graduation to PancakeSwap for an eligible token.
Users
/api/users/[wallet]Get user profile, created tokens, and trade history.
/api/users/[wallet]/avatarUpload a user avatar image.
Other
/api/uploadUpload an image file to IPFS via Pinata.
/api/swapGet PancakeSwap swap quote for a graduated token.
/api/statsGet platform-wide statistics (total tokens, volume, etc.).
/api/admin/flagFlag or unflag a token (admin only).
Troubleshooting
Port Conflicts
If port 3000, 3001, or 3002 is already in use, either stop the conflicting process or change the ports. Next.js runs on 3000 by default (use -p flag to change). WebSocket ports are configured via WS_PORT and WS_HTTP_PORT.
Database Connection Errors
- Verify PostgreSQL is running:
docker psorpg_isready. - Check that
DATABASE_URLmatches your PostgreSQL credentials and port. - Run
npx prisma db pushagain if tables are missing.
MetaMask Network Setup
If MetaMask does not connect or shows the wrong network, add BSC Testnet manually:
Network Name: BNB Smart Chain Testnet RPC URL: https://data-seed-prebsc-1-s1.binance.org:8545/ Chain ID: 97 Currency Symbol: tBNB Block Explorer: https://testnet.bscscan.com/
Contract Verification Failures
- Make sure the constructor arguments match exactly what was used during deployment (in wei).
- Wait a few minutes after deployment before verifying — BscScan may not have indexed the contract yet.
- Ensure Hardhat's
etherscanconfig includes a valid BscScan API key.
WebSocket Not Connecting
- Confirm the WebSocket server is running:
npm run ws. - Check that
NEXT_PUBLIC_WS_URLmatches the actual server address and port. - In production, ensure your reverse proxy (Nginx, Caddy) is configured to upgrade WebSocket connections.
Transactions Failing
- Make sure your wallet has enough BNB for gas fees.
- Check that
NEXT_PUBLIC_CONTRACT_ADDRESSis the correct deployed contract address for your network. - For testnet, get free tBNB from the BNB Chain faucet.
BSC PumpFun — Token Launchpad on BNB Chain
Downloaded from web3.market