A complete, production-ready Four.meme fork smart contract system for BNB Chain that enables users to create, launch, swap, and migrate meme tokens with advanced security features, fair launch mechanics, and comprehensive migration capabilities.
- πͺ No-Code Token Creation: Create meme tokens through smart contracts
- π Fair Launch Mechanics: No pre-sales or exclusive allocations
- π Token Swapping: Direct token-to-token swapping with real-time quotes
- π§ Liquidity Management: Add/remove liquidity with yield farming support
- π Price Oracle: Real-time price tracking and market data
- π Migration System: Token and platform migration capabilities
- π€ Anti-Bot Protection: Cooldown periods and transaction limits
- π Anti-Whale Protection: Maximum transaction and wallet limits
- π ReentrancyGuard: Protection against reentrancy attacks
- βΈοΈ Pausable: Emergency pause functionality
- π Ownable: Admin controls for platform management
- β Input Validation: Comprehensive parameter validation
- π Access Control: Role-based permissions
- π§ Automatic Liquidity: Direct integration with PancakeSwap
- π Liquidity Locking: Optional liquidity lock periods
- π₯ Deflationary Mechanism: Token burning capabilities
- π Migration Support: Token upgrades and platform migrations
- π Frontend Integration: Complete Web3 integration and React components
βββ contracts/ # Smart Contracts
β βββ MemeToken.sol # Standard meme token with security features
β βββ MemeTokenFactory.sol # Factory for creating tokens
β βββ LaunchPlatform.sol # Advanced launch platform with liquidity
β βββ TokenSwap.sol # Direct token-to-token swapping
β βββ LiquidityManager.sol # Liquidity management and yield farming
β βββ PriceOracle.sol # Price tracking and market data
β βββ TokenMigration.sol # Token migration and upgrades
β βββ PlatformMigration.sol # Platform-wide migration system
βββ scripts/ # Deployment & Interaction Scripts
β βββ deploy.js # Main deployment script
β βββ createToken.js # Token creation script
β βββ launchWithLiquidity.js # Launch with liquidity script
β βββ swapTokens.js # Token swapping script
β βββ manageLiquidity.js # Liquidity management script
β βββ migrateTokens.js # Token migration script
β βββ migratePlatform.js # Platform migration script
βββ test/ # Comprehensive Test Suite
β βββ MemeToken.test.js # Token contract tests
β βββ TokenMigration.test.js # Migration functionality tests
βββ frontend-examples/ # Frontend Integration Examples
β βββ web3-integration.js # Complete Web3 integration class
β βββ react-components.jsx # Ready-to-use React components
βββ deployments/ # Deployment records
βββ tokens/ # Created token records
βββ launches/ # Launch records
βββ swaps/ # Swap transaction records
βββ migrations/ # Migration records
βββ package.json # Dependencies and scripts
βββ hardhat.config.js # Hardhat configuration
βββ env.example # Environment variables template
βββ README.md # This file
- Node.js (v16 or higher)
- npm or yarn
- Git
- BNB Chain wallet (MetaMask recommended)
-
Clone the repository
git clone <repository-url> cd bnb-fourmeme-fork-smart-contract
-
Install dependencies
npm install # or yarn install -
Set up environment variables
cp env.example .env
Edit
.envwith your configuration:# Private key for deployment (without 0x prefix) PRIVATE_KEY=your_private_key_here # BSCScan API key for contract verification BSCSCAN_API_KEY=your_bscscan_api_key_here
-
Compile contracts
npm run compile
Deploy to BSC Testnet:
npm run deploy:testnetDeploy to BSC Mainnet:
npm run deploy:mainnetThis deploys all contracts:
- MemeTokenFactory
- LaunchPlatform
- TokenSwap
- LiquidityManager
- PriceOracle
- TokenMigration
- PlatformMigration
Edit scripts/createToken.js with your token parameters:
const TOKEN_NAME = "MyMemeToken";
const TOKEN_SYMBOL = "MMT";
const TOTAL_SUPPLY = ethers.utils.parseEther("1000000000"); // 1 billion
const MAX_TRANSACTION = ethers.utils.parseEther("10000000"); // 10M (1%)
const MAX_WALLET = ethers.utils.parseEther("50000000"); // 50M (5%)Run the script:
npx hardhat run scripts/createToken.js --network testnetEdit scripts/launchWithLiquidity.js with your parameters:
const BNB_LIQUIDITY = ethers.utils.parseEther("1.0"); // 1 BNB
const LIQUIDITY_PERCENT = 8000; // 80% of tokens
const LOCK_DURATION = 30 * 24 * 60 * 60; // 30 daysRun the script:
npx hardhat run scripts/launchWithLiquidity.js --network testnetEdit scripts/swapTokens.js with token addresses:
const TOKEN_IN_ADDRESS = "TOKEN_IN_ADDRESS_HERE";
const TOKEN_OUT_ADDRESS = "TOKEN_OUT_ADDRESS_HERE";
const SWAP_AMOUNT = ethers.utils.parseEther("1000"); // 1000 tokensRun the script:
npx hardhat run scripts/swapTokens.js --network testnetEdit scripts/manageLiquidity.js with your parameters:
const TOKEN_ADDRESS = "TOKEN_ADDRESS_HERE";
const BNB_AMOUNT = ethers.utils.parseEther("0.5"); // 0.5 BNB
const TOKEN_AMOUNT = ethers.utils.parseEther("1000000"); // 1M tokens
const ACTION = "add"; // "add", "remove", or "create"Run the script:
npx hardhat run scripts/manageLiquidity.js --network testnetStandard meme token with advanced security features
- ERC20 Compliance: Standard token functionality
- Anti-Bot Protection: 30-second cooldown periods
- Anti-Whale Protection: Configurable transaction/wallet limits
- Deflationary Mechanism: Token burning capabilities
- Trading Controls: Enable/disable trading functionality
- Excluded Addresses: DEX and contract addresses exempt from limits
Token creation factory with spam prevention
- Token Creation: Standardized token deployment
- User Limits: Maximum tokens per user (default: 5)
- Fee Management: Launch fees for platform sustainability
- Token Tracking: Complete metadata and history storage
- Admin Controls: Platform management and configuration
- Trading Enablement: Creator-controlled trading activation
Advanced launch platform with liquidity provision
- PancakeSwap Integration: Direct DEX integration
- Fair Launch Mechanics: No pre-sales or exclusive allocations
- Liquidity Locking: Optional lock periods for security
- Automatic Listing: Immediate DEX listing
- Configurable Parameters: Flexible launch configuration
- LP Token Burning: Optional liquidity token burning
Direct token-to-token swapping system
- Constant Product Formula: AMM-style price calculation
- Real-Time Quotes: Instant swap price calculation
- Fee Management: Configurable swap fees
- Transaction History: Complete swap record tracking
- Supported Tokens: Whitelist-based token support
- Anti-Dust Protection: Minimum swap amounts
Advanced liquidity management and yield farming
- PancakeSwap Integration: Direct liquidity provision
- Position Tracking: User liquidity position management
- LP Token Management: Liquidity token handling
- Yield Farming Ready: Compatible with farming protocols
- TVL Tracking: Total value locked monitoring
- Emergency Controls: Emergency withdrawal capabilities
Real-time price tracking and market data
- PancakeSwap Integration: Direct pair data access
- Price Calculation: Real-time token price in BNB
- Market Cap Calculation: Token market cap tracking
- Price Change Tracking: Percentage change monitoring
- USD Conversion: BNB price-based USD conversion
- Freshness Validation: Price data freshness checks
Token migration and upgrade system
- Multiple Migration Types: Token upgrade, platform migration, token swap
- Flexible Ratios: Configurable migration ratios
- Time Controls: Start/end time management
- User Tracking: Complete migration history
- Emergency Controls: Emergency pause and withdrawal
- Batch Migration: Admin batch migration capabilities
Platform-wide migration system
- Contract Migration: All platform contract upgrades
- Data Migration: User data, token data, liquidity data
- Version Control: Platform version tracking
- Progress Monitoring: Real-time migration progress
- Emergency Updates: Emergency contract address updates
- Migration Validation: Comprehensive migration validation
| Parameter | Description | Example | Default |
|---|---|---|---|
| Name | Token name | "MyMemeToken" | Required |
| Symbol | Token symbol | "MMT" | Required |
| Total Supply | Total token supply | 1,000,000,000 | Required |
| Max Transaction | Maximum transaction amount | 10,000,000 (1%) | Required |
| Max Wallet | Maximum wallet amount | 50,000,000 (5%) | Required |
| Parameter | Description | Range | Default |
|---|---|---|---|
| Liquidity Percent | Percentage of tokens for liquidity | 0-100% | 80% |
| BNB Liquidity | BNB amount for liquidity | > 0 | 0.5 BNB |
| Lock Duration | Liquidity lock period | 0-365 days | 30 days |
| Auto List | Automatically list on PancakeSwap | true/false | true |
| Burn Liquidity | Burn LP tokens after adding | true/false | true |
| Fee Type | Description | Default | Range |
|---|---|---|---|
| Launch Fee | BNB fee for token creation | 0.1 BNB | 0-1 BNB |
| Platform Fee | Percentage fee on transactions | 2.5% | 0-10% |
| Swap Fee | Fee for token swaps | 1% | 0-10% |
| Parameter | Description | Options | Default |
|---|---|---|---|
| Migration Type | Type of migration | TokenUpgrade, PlatformMigration, TokenSwap, LiquidityMigration | TokenUpgrade |
| Migration Ratio | New tokens per old token | Any ratio | 1:1 |
| Start Time | Migration start time | Unix timestamp | Required |
| End Time | Migration end time | Unix timestamp | Required |
| Max Amount | Maximum migration amount | Token amount | No limit |
| Burn Old Tokens | Burn old tokens after migration | true/false | true |
- Cooldown Period: 30-second cooldown between transactions
- Transaction Limits: Configurable maximum transaction amounts
- Wallet Limits: Configurable maximum wallet amounts
- Excluded Addresses: DEX and contract addresses exempt from limits
- Max Transaction: Prevents large single transactions (default: 1% of supply)
- Max Wallet: Prevents single wallet dominance (default: 5% of supply)
- Dynamic Limits: Admin-adjustable limits based on market conditions
- Whale Detection: Real-time monitoring of large transactions
- ReentrancyGuard: Protection against reentrancy attacks
- Pausable: Emergency pause functionality for all contracts
- Ownable: Multi-level admin controls and ownership management
- Input Validation: Comprehensive parameter validation and sanitization
- Access Control: Role-based permissions and authorization
- Emergency Controls: Emergency withdrawal and migration capabilities
- OpenZeppelin: Industry-standard security libraries
- Upgradeable: Migration system for contract upgrades
- Audit Ready: Clean, well-documented code for security audits
- Gas Optimization: Optimized for gas efficiency and cost reduction
| Parameter | Value |
|---|---|
| RPC URL | https://data-seed-prebsc-1-s1.binance.org:8545/ |
| Chain ID | 97 |
| Explorer | https://testnet.bscscan.com/ |
| PancakeSwap | https://pancake.kiemtienonline360.com/ |
| WBNB | 0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd |
| Parameter | Value |
|---|---|
| RPC URL | https://bsc-dataseed.binance.org/ |
| Chain ID | 56 |
| Explorer | https://bscscan.com/ |
| PancakeSwap | https://pancakeswap.finance/ |
| WBNB | 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c |
The system is pre-configured for BNB Chain with:
- PancakeSwap Router: Automatic DEX integration
- WBNB Support: Native BNB token wrapping
- Gas Optimization: Optimized for BSC gas costs
- Multi-RPC Support: Fallback RPC endpoints
const factory = await ethers.getContractAt("MemeTokenFactory", factoryAddress);
await factory.createToken(
"MyToken",
"MTK",
ethers.utils.parseEther("1000000000"), // 1B supply
ethers.utils.parseEther("10000000"), // 10M max tx (1%)
ethers.utils.parseEther("50000000"), // 50M max wallet (5%)
{ value: ethers.utils.parseEther("0.1") } // 0.1 BNB fee
);const launchPlatform = await ethers.getContractAt("LaunchPlatform", platformAddress);
const config = {
liquidityPercent: 8000, // 80% of tokens for liquidity
bnbLiquidity: ethers.utils.parseEther("1.0"), // 1 BNB
lockDuration: 30 * 24 * 60 * 60, // 30 days
autoList: true,
burnLiquidity: true
};
await launchPlatform.launchTokenWithLiquidity(
"MyToken",
"MTK",
ethers.utils.parseEther("1000000000"),
ethers.utils.parseEther("10000000"),
ethers.utils.parseEther("50000000"),
config,
{ value: totalCost }
);const tokenSwap = await ethers.getContractAt("TokenSwap", swapAddress);
// Get swap quote
const [amountOut, fee] = await tokenSwap.getSwapQuote(
tokenInAddress,
tokenOutAddress,
ethers.utils.parseEther("1000")
);
// Execute swap
await tokenSwap.swapTokens(
tokenInAddress,
tokenOutAddress,
ethers.utils.parseEther("1000")
);const liquidityManager = await ethers.getContractAt("LiquidityManager", liquidityAddress);
// Add liquidity
await liquidityManager.addLiquidity(
tokenAddress,
ethers.utils.parseEther("0.5"), // 0.5 BNB
ethers.utils.parseEther("1000000"), // 1M tokens
{ value: ethers.utils.parseEther("0.5") }
);
// Remove liquidity
await liquidityManager.removeLiquidity(
tokenAddress,
ethers.utils.parseEther("100") // 100 LP tokens
);const tokenMigration = await ethers.getContractAt("TokenMigration", migrationAddress);
// Create migration
const migrationConfig = {
oldToken: oldTokenAddress,
newToken: newTokenAddress,
migrationRatio: ethers.utils.parseEther("1"), // 1:1 ratio
startTime: Math.floor(Date.now() / 1000) + 3600, // Start in 1 hour
endTime: Math.floor(Date.now() / 1000) + 86400, // End in 24 hours
maxMigrationAmount: ethers.utils.parseEther("1000000"),
migrationType: 0, // TokenUpgrade
requiresApproval: true,
burnOldTokens: true
};
await tokenMigration.createMigration(migrationId, migrationConfig);
await tokenMigration.startMigration(migrationId);
// User migration
await tokenMigration.migrateTokens(migrationId, ethers.utils.parseEther("1000"));const priceOracle = await ethers.getContractAt("PriceOracle", oracleAddress);
// Update token price
await priceOracle.updateTokenPrice(tokenAddress);
// Get token price
const [price, valid] = await priceOracle.getTokenPrice(tokenAddress);
// Get market cap
const [marketCap, valid] = await priceOracle.getTokenMarketCap(
tokenAddress,
totalSupply
);# Run all tests
npm test
# Run specific test file
npx hardhat test test/MemeToken.test.js
# Run tests with gas reporting
REPORT_GAS=true npm test# Compile contracts
npm run compile
# Deploy to testnet
npm run deploy:testnet
# Deploy to mainnet
npm run deploy:mainnet# Verify on BSCScan
npx hardhat verify --network mainnet <CONTRACT_ADDRESS>
# Verify with constructor arguments
npx hardhat verify --network mainnet <CONTRACT_ADDRESS> "constructor_arg1" "constructor_arg2"The project includes complete frontend integration examples:
// Import the Web3 integration class
import { FourMemeWeb3 } from './frontend-examples/web3-integration.js';
// Initialize
const web3 = new FourMemeWeb3(provider, signer);
// Create token
const result = await web3.createToken({
name: "MyToken",
symbol: "MTK",
totalSupply: "1000000000",
maxTransaction: "10000000",
maxWallet: "50000000"
});Ready-to-use React components are available in frontend-examples/react-components.jsx:
TokenCreator- Token creation formTokenSwapper- Token swapping interfaceLiquidityManager- Liquidity managementPriceDisplay- Price tracking component
# Set up token migration
npx hardhat run scripts/migrateTokens.js --network testnet# Set up platform migration
npx hardhat run scripts/migratePlatform.js --network testnetMIT License - see LICENSE file for details.
This is a fork of Four.meme for educational and development purposes. Use at your own risk. Always conduct thorough testing before deploying to mainnet.
- Audit Recommended: Have contracts audited before mainnet deployment
- Test Thoroughly: Use testnet extensively before production
- Monitor Activity: Keep track of all contract interactions
- Emergency Procedures: Have emergency pause and migration procedures ready
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run tests:
npm test - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Submit a pull request
- Follow Solidity style guide
- Add comprehensive tests for new features
- Update documentation for API changes
- Ensure all tests pass before submitting PR
- GitHub Issues: Create an issue for bugs or feature requests
- Documentation: Check this README and inline code comments
- Community: Join our Discord/Telegram for discussions
When reporting issues, please include:
- Contract addresses and transaction hashes
- Network (testnet/mainnet)
- Steps to reproduce
- Expected vs actual behavior
- Screenshots if applicable
We welcome feature requests! Please describe:
- The problem you're trying to solve
- Your proposed solution
- Any alternatives you've considered
- Token creation and management
- Fair launch mechanics
- Token swapping
- Liquidity management
- Price oracle
- Migration system
- Frontend integration
- Multi-signature wallet support
- Advanced analytics dashboard
- Mobile app integration
- Cross-chain bridge support
- NFT integration
- Governance token system
Ready to launch your meme token? Follow our Quick Start Guide and have your token live on BNB Chain in minutes!
Happy Meme Token Launching! ππͺ