The BasicLicenseSale contract manages the sale of licenses using USDC as payment, with configurable limits and whitelist functionality.
Security Note: BasicLicenseSale.sol has not been audited and is provided "as is," without any express or implied warranties, including but not limited to warranties of merchantability, fitness for a particular purpose, or non-infringement. Projects must independently test, verify, and validate the code before use and assume full responsibility and all risks associated with its deployment. The design is based on this contract, originally used for the CX-Chain node sale.
- License sales management with USDC payments
- Configurable purchase limits per address
- Whitelist functionality for access control
- Fund collection and treasury management
The following parameters must be set during contract deployment:
treasury: Address where all collected funds will be transferredSecurity Note: Ensure this is a secure, multi-sig wallet or similar secure address
usdc: USDC token contract address- Avalanche Mainnet:
0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E - Avalanche Testnet:
0x5425890298aed601595a70AB815c96711a31Bc65
- Avalanche Mainnet:
Important: Before deployment, customize these values according to your project's specific requirements:
- Adjust price based on your license valuation
- Set appropriate limits for your use case
- Configure whitelist settings as needed
price: 0.01 USDC per license (10,000 with 6 decimals)maxLicenses: 250 licenses per address limitmaxTotalSupply: 1000 total licenses limitsupply: tracks total licenses soldsalesActive: controls if sales are enabledisWhitelistEnabled: controls whitelist functionality
buyers[]: array of all addresses that have purchased licenseslicensesPurchased: mapping of address to number of licenses purchasedwhitelist: mapping of address to whitelist status
buy(uint256 licenseAmount): Purchase licenses with USDC- Checks whitelist, limits, and USDC balance/allowance
setLicensePrice: Update license pricesetMaxLicensesPerAddress: Update per-address limitsetMaxTotalSupply: Update total supply limitsetWhitelistEnabled: Toggle whiteliststartLicenseSales/stopLicenseSales: Control sales statuswithdrawToTreasury: Withdraw collected USDC
addToWhitelist: Add address to whitelistremoveFromWhitelist: Remove address from whitelist
getAllBuyers: Get all buyers and their license countslicensesPurchased: Get licenses purchased by an address (public mapping)whitelist: Check whitelist status (public mapping)
- Uses
SafeERC20for USDC transfers - Implements
ReentrancyGuard - Owner-only admin functions
- Whitelist system for access control
- Configurable limits and controls
LicensePurchased: Emitted on license purchasePriceUpdated: Emitted on price changeSalesStatusChanged: Emitted on sales status changeWhitelistStatusChanged: Emitted on whitelist status changeMaxLicensesUpdated: Emitted on max licenses limit changeMaxTotalSupplyUpdated: Emitted on total supply limit change
The contract is designed to be secure, flexible, and gas-efficient, with clear separation between user and admin functions.