DittocoinCrowdSale Contract
https://bscscan.com/address/0xd46dda71ac7b061c3aa3315078ae855296233377
Implementation Notes
Our public sale contract CrowdSale is adapted from the SettleMint ERC-20 Crowdsale template. It uses OpenZeppelin security primitives and an a Chainlink price feed for BNB price in USD. The only functional change vs. SettleMint’s sample is removing the whitelist so anyone can buy when the sale is unpaused. No additional sale powers or admin backdoors were added.
Key Components
- SettleMint Crowdsale template (source of truth)
- OpenZeppelin primitives: AccessControl, Pausable, ReentrancyGuard, ERC165, IERC20. These are widely audited building blocks used to gate admin actions, pause sales, and prevent reentrancy.
- Chainlink oracle: We used Chainlink’s AggregatorV3Interface to fetch the live USD price of BNB on-chain. This ensures that token purchases during the crowdsale are automatically priced against the current, tamper-resistant BNB/USD rate supplied by Chainlink’s decentralized oracle network. By integrating this feed, contributors receive a fair and transparent exchange rate in real time, without relying on any centralized pricing source.
What We Changed vs the Template (and Why)
- Removed whitelist logic → public sale: anyone can purchase while the contract is not paused.
- Kept admin surface minimal:
- Admins can pause/unpause, withdraw unsold tokens, and call externalBuyTokens (for off-chain/fiat allocations recorded on-chain).
- No functions to mint new sale tokens, drain buyer funds, or alter vesting after deployment.
- Pricing: kept the same mechanism: getTokenAmount(wei) (public buy) and getWeiAmount(tokenAmount) (admin-recorded purchases). If an oracle is configured, USD pricing comes from Chainlink; otherwise the explicit fallback is used (documented below).
What Stayed the Same (No New Powers)
- Funds flow: ETH/BNB received by buyTokens is forwarded to the treasury wallet (_forwardFunds()), exactly as in standard crowdsales.
- Reentrancy safety: both buyTokens and externalBuyTokens are nonReentrant.
- Pause safety: both purchase paths require whenNotPaused.