BSC Token Presale DApp with P2P Market, Boost Vault & Auto-Liquidity
Full-stack token presale platform for BNB Smart Chain
Description
BSC Token Presale DApp with P2P Market, Boost Vault & Auto-Liquidity
Full-stack token presale platform for BNB Smart Chain with multi-stage pricing, token locking bonuses, peer-to-peer sell orders, referral system, and automatic liquidity allocation. Solidity contracts + React frontend, ready to deploy.
What This Is
A complete presale system for launching a token sale on BSC. Buyers purchase your token with BNB, USDT, or USDC through a modern web interface. The sale runs in stages with increasing prices, and every payment is automatically split between your owner wallet, a liquidity wallet, and referral commissions.
What makes this different from a basic presale contract is the built-in Emergency Market — a P2P order book where presale holders can list tokens for sale at a discount before your token is listed on a DEX. This gives your community secondary liquidity without needing a PancakeSwap listing, and you collect a protocol fee on every trade.
It also includes a Boost Vault where buyers can lock their tokens for 30, 60, or 90 days and receive bonus tokens as a reward. Earlier stages offer higher multipliers, which incentivizes buying early and locking long.
What You Get
You receive all source files — Solidity contracts, React frontend, deployment scripts, and documentation. Nothing is hidden or obfuscated.
Smart Contracts (Solidity 0.8.24)
- PresaleVault.sol — Main presale contract handling token sales, payment splitting, boost locking, and referral tracking
- EmergencyMarket.sol — P2P trading contract with order book, escrow, and protocol fees
- Deploy.s.sol — Foundry script for BSC mainnet deployment
- DeployTestnet.s.sol — Foundry script that deploys everything (mock tokens, price feeds, vault) for testing
- DeployEmergencyMarket.s.sol — Separate deploy script for the market contract
- MockERC20.sol and MockPriceFeed.sol — Test helpers for local/testnet development
- PresaleVault.t.sol — Foundry test suite
Frontend (React + TypeScript)
- 4-tab presale widget — Buy, Boost, Market, More
- Dark and light theme with toggle and localStorage persistence
- Wallet connection via Reown AppKit (supports MetaMask, Trust Wallet, WalletConnect, Coinbase Wallet, and 100+ others)
- Responsive layout — works on desktop and mobile
- 11 shadcn/ui components — buttons, cards, inputs, tabs, sliders, dialogs
- 3 custom hooks — usePresaleData, usePresaleActions, useEmergencyMarket
Documentation
- documentation.html — 1,600+ line standalone documentation site with sidebar navigation, dark/light theme, code blocks with copy buttons, and full setup instructions. Accessible from the frontend at
/documentation.html.
Features
Multi-Stage Presale
The sale runs across multiple stages (default: 3). Each stage has its own price, token allocation, time window, minimum buy, and per-wallet maximum. Price increases with each stage. The frontend shows a live countdown, progress bar, and current price.
Payment Methods
Buyers can pay with BNB (native), USDT, or USDC. Token prices are calculated in real-time using Chainlink price feeds. You can add more ERC20 payment tokens after deployment by calling a single function.
Automatic Payment Splitting
Every purchase is split in one transaction:
- Referral commission (default 3%) sent directly to the referrer
- Liquidity allocation (default 10%) sent to a dedicated liquidity wallet
- Owner share (remainder) sent to your owner wallet
No manual distribution needed. The liquidity and referral percentages are set at deployment.
Boost Vault (Token Locking)
Buyers lock purchased tokens for a chosen duration and receive bonus tokens:
| Lock Period | Multiplier |
|---|---|
| 30 days | 1.2x |
| 60 days | 1.5x |
| 90 days | 2.0x |
Earlier stages have a higher base multiplier, so locking in Stage 1 earns significantly more bonus tokens than locking in Stage 3. After the lock period, users claim their original tokens plus the bonus.
Emergency Market (P2P Trading)
An optional contract that lets presale holders sell tokens before your DEX listing:
- Sellers list tokens at a discount (1–50% below current presale price)
- Tokens are held in escrow by the contract
- Buyers can fill orders with BNB or stablecoins
- A protocol fee (default 2%) is collected on every trade
- Sellers can cancel unfilled orders and reclaim tokens
You can deploy the market separately or skip it entirely. The frontend Market tab appears only when the market address is configured.
Referral System
On-chain referral tracking built into the presale contract:
- Referral links use a URL parameter (
?ref=0xAddress) - Referrers must have purchased tokens themselves
- Commission is paid instantly in the same transaction (BNB for BNB purchases, tokens for token purchases)
- The frontend generates a copy-to-clipboard referral link in the More tab
Admin Controls
All admin functions are owner-only:
- Pause / Unpause — freeze all buying, locking, and market activity
- Whitelist / Remove tokens — add or remove ERC20 payment options
- Withdraw unsold tokens — reclaim remaining allocation after the sale ends
- Transfer ownership — 2-step transfer (PresaleVault uses Ownable2Step for safety)
- Set market fees — adjust protocol fee and max discount on the Emergency Market
- Withdraw fees — collect accumulated protocol fees from the market
Contract Security
- Ownable2Step — ownership transfer requires the new owner to accept (prevents accidental loss)
- ReentrancyGuard — protects all payment functions
- Pausable — emergency stop for all operations
- SafeERC20 — safe token transfer handling
- Chainlink oracles — real-time pricing with staleness checks (1-hour threshold)
Frontend Details
The interface is a single widget (460px max-width) with 4 tabs:
Buy Tab — Token selector (BNB/USDT/USDC), amount input with balance display and quick-select buttons (25%, 50%, 75%, MAX), live token output preview, countdown timer, stage progress bar, and transaction status flow.
Boost Tab — Tier selection pills, amount input with bonus preview, list of active locks with unlock countdown and claim buttons.
Market Tab — Segmented view for buying and selling. Buy side shows active orders with discount badges. Sell side has amount input, discount slider, and price comparison. Shows your active orders with cancel option.
More Tab — Investment summary (total spent, locks, referral earnings), referral link with copy button, links to import token to wallet, view contract on BscScan, and view liquidity wallet.
Tech Stack
| Layer | Technology |
|---|---|
| Smart Contracts | Solidity 0.8.24, OpenZeppelin v5, Chainlink v0.8 |
| Build & Deploy | Foundry (forge, cast) |
| Frontend | React 19, TypeScript 5.9, Vite 7 |
| Styling | Tailwind CSS 4, shadcn/ui, Framer Motion 12 |
| Web3 | Wagmi 3, Viem 2, Reown AppKit 1.8 |
| Wallet Support | MetaMask, Trust Wallet, WalletConnect, Coinbase Wallet, 100+ others |
| Chain | BNB Smart Chain (Testnet 97 / Mainnet 56) |
| Price Feeds | Chainlink BNB/USD oracle |
Configuration
All settings are configured through environment variables and deploy scripts. No code changes needed for basic customization.
Frontend (.env file):
- Project name and token symbol
- Contract addresses (PresaleVault, EmergencyMarket, USDT, USDC)
- Reown Project ID (free from cloud.reown.com)
- Chain ID (97 for testnet, 56 for mainnet)
Contract deployment scripts:
- Stage prices, allocations, and time windows
- Boost tier durations and multipliers
- Liquidity and referral percentages
- Owner and liquidity wallet addresses
- Chainlink price feed addresses
The Emergency Market is fully optional — leave the address empty in .env to hide the Market tab, or don't deploy the contract at all.
Requirements
- Node.js 18+ — to build and run the frontend
- Foundry — to compile and deploy contracts (free, installs via one command)
- A Reown Project ID — free account at cloud.reown.com for wallet connections
- BNB for gas — deployer wallet needs BNB for contract deployment
- Your ERC20 token — already deployed (for mainnet; testnet script creates a mock token)
Deployment
Contracts can be deployed via Foundry CLI or Remix IDE. The documentation covers both methods step by step.
Testnet (one command): A single Foundry script deploys mock tokens, price feeds, and the PresaleVault. Copy the output addresses into .env and you're running.
Mainnet: Point the deploy script at your token address, set your wallets and stage config, and deploy. Then fund the vault with your sale tokens and whitelist stablecoins.
Frontend: npm install then npm run build produces a static dist/ folder. Upload to any hosting (Vercel, Netlify, or any static host).
What This Does Not Include
- No backend or database — everything runs on-chain and client-side
- No token contract — you deploy your own ERC20 separately (or use the included mock for testing)
- No DEX listing automation — the liquidity wallet accumulates funds, but adding liquidity to PancakeSwap is done manually
Disclaimer: Web3.Market is a marketplace platform that facilitates the sale of digital products between independent sellers and buyers. We do not develop, endorse, or guarantee any product listed on this platform. All products are provided by third-party sellers and are sold "as is." Web3.Market assumes no responsibility or liability for the functionality, security, legality, or any use or misuse of products purchased through this platform. Buyers are solely responsible for evaluating the suitability of any product for their intended purpose and for ensuring compliance with all applicable laws and regulations. By purchasing, you acknowledge that Web3.Market shall not be held liable for any direct, indirect, incidental, or consequential damages arising from the use of any product.
One-time payment • Lifetime access
Product Info
RPC Providers
Need a reliable RPC endpoint for your dApp? Get started with these trusted providers:
