BuyOnlyToken is a production-ready ERC-20 token implementation with advanced features including:
- Buy-Only Mechanism: Sells are blocked by default until explicitly enabled by governance
- Multi-Chain Support: Deployable on Base and BSC (Binance Smart Chain)
- Fee System: Configurable buy/sell fees with automatic distribution
- Anti-Bot Protection: Launch protection with transaction limits and cooldowns
- Governance: Timelock and multisig support for critical functions
- Vesting: Linear and cliff vesting schedules for team/investors
- Presale: Whitelist-based presale with contribution limits
- DeFi Integration: Uniswap V3 concentrated liquidity and DODO PMM support
- ERC-20 standard compliance
- EIP-2612 permit functionality
- Snapshot mechanism for governance voting
- Pausable transfers for emergencies
- Blacklist/whitelist functionality
- Fee exemptions for specific addresses
- Blocks transfers TO liquidity pools (sells) by default
- Allows transfers FROM liquidity pools (buys)
- Whitelist bypass for market makers and specific addresses
- Owner-controlled sell enabling through timelock
- Buy Fee: 3% default (configurable)
- Sell Fee: 5% default (configurable)
- Distribution:
- Treasury: 50%
- Buyback: 30%
- Burn: 20%
- Anti-bot protection during launch
- Maximum transaction limits
- Maximum wallet limits
- Cooldown between transactions
- Gas price limits
- Timelock governance (2-day minimum delay)
- Multisig support
- Foundry
- Node.js >= 16
- Git
# Clone the repository
git clone <repository-url>
cd buy-only-token
# Install dependencies
npm install
# Install Foundry dependencies
forge install
Copy .env.example
to .env
and configure:
cp .env.example .env
Required environment variables:
PRIVATE_KEY
: Deployer wallet private keyBASE_RPC_URL
: Base network RPC endpointBSC_RPC_URL
: BSC network RPC endpointBASESCAN_API_KEY
: Basescan API key for verificationBSCSCAN_API_KEY
: BscScan API key for verification- Token parameters (name, symbol, supply, etc.)
- Contract addresses (treasury, buyback, multisig)
# Run tests
forge test
# Run tests with gas reporting
forge test --gas-report
# Run specific test
forge test --match-test testBuyOnlyMechanism -vvv
# Deploy to Base Sepolia
forge script script/Deploy.s.sol:Deploy --rpc-url base-sepolia --broadcast --verify
# Deploy to BSC Testnet
forge script script/Deploy.s.sol:Deploy --rpc-url bsc-testnet --broadcast --verify
# Deploy to Base Mainnet
forge script script/Deploy.s.sol:Deploy --rpc-url base --broadcast --verify
# Deploy to BSC Mainnet
forge script script/Deploy.s.sol:Deploy --rpc-url bsc --broadcast --verify
After deployment, add liquidity using:
# Add liquidity (configure amounts in .env)
forge script script/AddLiquidity.s.sol:AddLiquidity --rpc-url <network> --broadcast
- Concentrated Liquidity: Deploy liquidity in a tight range (±5%) around target price
- Capital Efficiency: Small amount of capital can maintain price stability
- Example: For $0.001 initial price with $10,000 liquidity:
Price Range: $0.00095 - $0.00105 Token Amount: 10,000,000 MBOT USDC/ETH Amount: $10,000
- Set Initial Price (i parameter): Defines the initial price point
- Set Slippage (k parameter): Controls price sensitivity (0.1-0.5 recommended)
- Example Configuration:
i = 0.001 * 10^18 // $0.001 per token k = 0.1 * 10^18 // 10% slippage parameter
// Through timelock (2-day delay)
1. Schedule: timelock.schedule(token, 0, setSellAllowed(true), ...)
2. Wait 2 days
3. Execute: timelock.execute(token, 0, setSellAllowed(true), ...)
// Mark address as liquidity pool
token.setLiquidityPool(poolAddress, true)
// Remove pool designation
token.setLiquidityPool(poolAddress, false)
// Update fees (max 20%)
token.setFees(300, 500) // 3% buy, 5% sell
// Update fee recipients
token.setFeeAddresses(treasury, buyback)
// Update distribution
token.setFeeShares(5000, 3000, 2000) // 50%, 30%, 20%
- Honeypot Perception: Blocking sells creates honeypot appearance
- Trust Issues: Requires strong community trust and transparency
- Liquidity Risk: Limited sell-side liquidity until enabled
- Regulatory Concerns: May face scrutiny in some jurisdictions
- Full Disclosure: Clearly communicate buy-only period to all buyers
- Timelock Governance: All critical functions behind 2-day timelock
- Multisig Control: Use multisig wallet for ownership
- Public Roadmap: Publish clear timeline for enabling sells
- Third-Party Audit: Get professional security audit before launch
- Renounce Carefully: Don't renounce ownership until fully tested
Approximate gas costs (Base/BSC):
Function | Gas Usage | Cost @ 30 Gwei |
---|---|---|
Transfer | ~65,000 | ~$0.05 |
Transfer with fee | ~95,000 | ~$0.08 |
Buy from pool | ~110,000 | ~$0.10 |
Sell to pool | ~115,000 | ~$0.10 |
Claim vesting | ~85,000 | ~$0.07 |
Run comprehensive test suite:
# Unit tests
forge test --match-contract BuyOnlyTokenTest
# Integration tests
forge test --match-contract IntegrationTest
# Fuzz tests
forge test --match-test testFuzz
# Coverage report
forge coverage
Before audit, ensure:
- ✅ All tests passing
- ✅ 100% test coverage for critical paths
- ✅ Deployment on testnet verified
- ✅ Documentation complete
- ✅ Known issues documented
- ✅ Slither/Mythril analysis complete
See AUDIT_CHECKLIST.md
for detailed audit requirements.
See DEPLOY_CHECKLIST.md
for step-by-step deployment guide.
- Mainnet Chain ID: 8453
- Testnet (Sepolia): 84531
- Block Explorer: https://basescan.org
- Mainnet Chain ID: 56
- Testnet Chain ID: 97
- Block Explorer: https://bscscan.com
⚠️ IMPORTANT NOTICE FOR BUYERS ⚠️
This token has a BUY-ONLY period active. This means:
- ✅ You CAN buy tokens from the liquidity pool
- ❌ You CANNOT sell tokens back to the pool yet
- 📅 Selling will be enabled on [DATE] via governance vote
- 🔒 This change requires a 48-hour timelock delay
- 👥 Decision made by multisig holders: [ADDRESSES]
This mechanism is designed to:
1. Prevent bot manipulation during launch
2. Build initial liquidity and price stability
3. Reward early supporters when selling enables
INVEST AT YOUR OWN RISK. This is visible on-chain and cannot be hidden.
MIT License - See LICENSE file for details
This software is provided "as is", without warranty of any kind. The authors are not responsible for any losses or damages arising from its use. Always conduct your own research and get a professional audit before deploying to mainnet.