BSC PumpFun

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 Formula
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 token
  • slope = 1 — controls how steeply the price rises
  • maxSupply = 1,000,000,000 tokens (1 billion)
  • creationFee = 0.02 BNB — paid on token creation
  • hardCap = 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 addLiquidityETH function.
  • 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 Graduated event 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:

Terminal
# 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:

Terminal
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-only

PostgreSQL connection string.

Example: postgresql://pumpfun:secret@localhost:5433/bsc_pumpfun_launchpad

BSC Chain

NEXT_PUBLIC_BSC_CHAIN_IDpublic

Chain ID. Use 97 for BSC Testnet or 56 for BSC Mainnet.

Example: 97

NEXT_PUBLIC_BSC_RPC_URLpublic

RPC endpoint for the BNB Smart Chain network.

Example: https://data-seed-prebsc-1-s1.binance.org:8545/

NEXT_PUBLIC_CONTRACT_ADDRESSpublic

Deployed PumpLaunchpad contract address.

Example: 0x1234...abcd

Wallet Connection

NEXT_PUBLIC_WALLETCONNECT_PROJECT_IDpublic

WalletConnect Cloud project ID. Get one free at cloud.walletconnect.com.

Example: abc123def456

Platform Settings

NEXT_PUBLIC_HARD_CAP_BNBpublic

Graduation threshold in BNB. Must match the hardCap constructor arg of the deployed contract.

Example: 0.5

NEXT_PUBLIC_CREATION_FEE_BNBpublic

Token creation fee in BNB. Must match the creationFee constructor arg of the deployed contract.

Example: 0.02

Admin

ADMIN_WALLETserver-only

Admin wallet address for server-side authorization checks.

Example: 0xYourAdminWalletAddress

NEXT_PUBLIC_ADMIN_WALLETpublic

Admin wallet address exposed to the client for UI visibility (e.g., showing admin controls).

Example: 0xYourAdminWalletAddress

DEPLOYER_PRIVATE_KEYserver-only

Private key of the deployer wallet. Used for contract deployment and server-side graduation transactions.

Warning

Never commit DEPLOYER_PRIVATE_KEY to version control. Keep it in .env.local only and add that file to your .gitignore.

IPFS / Pinata

PINATA_JWTserver-only

Pinata JWT token for uploading token images to IPFS.

NEXT_PUBLIC_PINATA_GATEWAYpublic

Pinata gateway domain for loading IPFS images.

Example: gateway.pinata.cloud

WebSocket Server

NEXT_PUBLIC_WS_URLpublic

WebSocket server URL. Clients connect here for real-time updates.

Example: ws://localhost:3001

WS_PORTserver-only

Port for the WebSocket server.

Example: 3001

WS_HTTP_PORTserver-only

Port for the WebSocket HTTP broadcast endpoint (used internally by API routes).

Example: 3002

WS_HTTP_URLserver-only

Internal URL for the HTTP broadcast endpoint.

Example: http://localhost:3002

PancakeSwap

NEXT_PUBLIC_PANCAKESWAP_ROUTERpublic

PancakeSwap Router contract address. Differs between testnet and mainnet.

Example: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 (testnet)

NEXT_PUBLIC_PANCAKESWAP_FACTORYpublic

PancakeSwap Factory contract address.

Example: 0x6725F303b657a9451d8BA641348b6761A6CC7a17 (testnet)

Application

NEXT_PUBLIC_APP_URLpublic

Base 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:

Terminal
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:

Terminal
npx prisma db push

To explore the database with a visual GUI:

Terminal
npx prisma studio

Smart Contract Deployment

1. Compile

Terminal
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

Terminal
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:

Terminal
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:

contracts/scripts/deploy.ts
const creationFee = ethers.parseEther("0.02"); // Change creation fee here
const hardCap = ethers.parseEther("0.05");      // Change hard cap here

Running the Application

Development

Start the Next.js development server with Turbopack for fast refresh:

Terminal
npm run dev

In a separate terminal, start the WebSocket server for real-time updates:

Terminal
npm run ws

Open http://localhost:3000 in your browser.

Production

Terminal
# Build the Next.js application
npm run build

# Start the production server
npm start

# Start the WebSocket server (separate process)
npm run ws

Tip

Use a process manager like 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

.env.local
# 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

Terminal
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:

.env.local
# 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:

.env.local
NEXT_PUBLIC_HARD_CAP_BNB="10"
NEXT_PUBLIC_CREATION_FEE_BNB="0.1"

Warning

Double-check all addresses and parameters before deploying to mainnet. Mainnet deployments use real BNB and are irreversible.

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:

src/app/globals.css
--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.svg with your own SVG logo.
  • Site title & description: Edit the metadata export in src/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

GET
/api/tokens

List tokens with pagination, filtering, and sorting. Query params: page, limit, search, sort, graduated.

POST
/api/tokens

Create a new token record after on-chain creation.

GET
/api/tokens/trending

Get trending tokens based on recent trading volume.

GET
/api/tokens/[tokenAddress]

Get details for a single token by its contract address.

GET
/api/tokens/[tokenAddress]/trades

Get trade history for a token with pagination.

POST
/api/tokens/[tokenAddress]/trades

Record a new trade (buy or sell) for a token.

GET
/api/tokens/[tokenAddress]/chart

Get OHLCV candlestick chart data for a token.

GET
/api/tokens/[tokenAddress]/holders

Get the list of token holders and their balances.

GET
/api/tokens/[tokenAddress]/comments

Get comments posted on a token.

POST
/api/tokens/[tokenAddress]/comments

Post a new comment on a token.

POST
/api/tokens/[tokenAddress]/graduate

Trigger graduation to PancakeSwap for an eligible token.

Users

GET
/api/users/[wallet]

Get user profile, created tokens, and trade history.

POST
/api/users/[wallet]/avatar

Upload a user avatar image.

Other

POST
/api/upload

Upload an image file to IPFS via Pinata.

GET
/api/swap

Get PancakeSwap swap quote for a graduated token.

GET
/api/stats

Get platform-wide statistics (total tokens, volume, etc.).

POST
/api/admin/flag

Flag 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 ps or pg_isready.
  • Check that DATABASE_URL matches your PostgreSQL credentials and port.
  • Run npx prisma db push again if tables are missing.

MetaMask Network Setup

If MetaMask does not connect or shows the wrong network, add BSC Testnet manually:

BSC Testnet Network Details
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 etherscan config includes a valid BscScan API key.

WebSocket Not Connecting

  • Confirm the WebSocket server is running: npm run ws.
  • Check that NEXT_PUBLIC_WS_URL matches 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_ADDRESS is 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