BSC Token Presale with Randomized Allocation - Chainlink VRF Powered
A ready-to-deploy token presale system for BNB Smart Chain
Description
BSC Token Presale with Randomized Allocation — Chainlink VRF Powered
A ready-to-deploy token presale system for BNB Smart Chain that adds a twist to the standard sale format: buyers don't get a fixed token amount. Instead, they pick a price tier and receive a random number of tokens within that tier's range, determined by Chainlink VRF on-chain randomness. Payments go straight to the project owner's wallet — nothing sits in the contract.
What It Does
Buyers connect their wallet, choose a tier (e.g. Bronze, Silver, Gold), enter a BNB amount, and hit buy. The contract verifies the payment falls within the tier's USD range using a live Chainlink BNB/USD price feed, forwards the BNB to the owner immediately, and requests a random number from Chainlink VRF v2.5. A few seconds later, the random result comes back on-chain and the buyer receives their tokens — somewhere between the tier's minimum and maximum. Every result is verifiable on-chain. No one can predict or manipulate the outcome.
The frontend presents this as a slot-machine-style spin. Numbers roll while waiting for the VRF response, then decelerate and lock in the final amount. It's a more engaging way to run a token sale compared to a flat-rate presale.
What's Included
Smart Contracts (Solidity 0.8.28, Foundry)
- FunOffering presale contract with tiered pricing, Chainlink VRF v2.5 integration, and Chainlink price feed for BNB/USD conversion
- Configurable purchase tiers — set USD price ranges and token allocation ranges per tier, add or update tiers after deployment
- BNB payments with live USD conversion via Chainlink price feed
- Stablecoin payment support — whitelist any stablecoin (USDT, USDC, etc.) with automatic decimal normalization
- Total distribution cap to limit the presale supply
- Pause/unpause functionality for emergency control
- Owner functions to withdraw funds, adjust VRF parameters, and manage tiers
- Test ERC-20 token contract for development and testing
- Deployment scripts for BSC Testnet (with mainnet addresses documented)
- Full test suite — unit tests, integration tests, fuzz tests, access control tests
Frontend (React, TypeScript, Vite)
- Single-page presale widget with wallet connection via Reown AppKit (WalletConnect, MetaMask, Coinbase Wallet, and others)
- Slot machine animation that spins while waiting for the VRF result and decelerates to reveal the final token amount
- Tier selection with live pricing pulled directly from the contract
- BNB amount input with quick-fill buttons (min, 50%, max) and live USD conversion
- Transaction history panel showing past purchases for the connected wallet
- Confetti and sound effects on successful purchases (sounds are synthesized, no audio files)
- Progress bar showing total distribution vs. cap
- Dark theme with a cyber/terminal aesthetic
- Iframe embedding support — drop it into any website with a single embed tag, with optional contract address override via URL parameter
- Responsive design, works on mobile
Documentation
- Self-contained HTML documentation page served at /docs/ on the deployed frontend
- Covers everything: deployment, tier configuration, VRF setup, frontend customization, Vercel deployment, contract administration, and network addresses for both BSC Testnet and Mainnet
Technical Details
- Solidity 0.8.28 with OpenZeppelin v5 (ReentrancyGuard, Pausable, SafeERC20)
- Chainlink VRF v2.5 for provably fair randomness
- Chainlink Price Feed for real-time BNB/USD conversion
- Foundry for compilation, testing, and deployment
- React 19, TypeScript, Vite 7, Tailwind CSS 4
- wagmi v2 + viem v2 for contract interactions
- Reown AppKit for wallet connectivity
- No external databases or backend — everything runs on-chain and client-side
How Tiers Work
Each tier defines a USD price range and a token range. For example:
| Tier | Buy-in (USD) | Token Range |
|---|---|---|
| Bronze | $10 – $50 | 1,000 – 5,000 |
| Silver | $50 – $200 | 5,000 – 20,000 |
| Gold | $200 – $1,000 | 20,000 – 100,000 |
The owner can add up to any number of tiers, update ranges, or disable tiers at any time after deployment. USD values are checked against the live BNB price so tier bounds stay consistent regardless of BNB price movement.
What You Need to Deploy
- A BNB Smart Chain wallet with BNB for gas
- A Chainlink VRF v2.5 subscription funded with LINK tokens
- An ERC-20 token to distribute (or use the included test token)
- A Reown project ID (free) for wallet connectivity
- Foundry installed for contract compilation and deployment
- Node.js for the frontend
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:
