COFFEE MOON Honeypot
What happened
COFFEE MOON (CMOON) is a BNB Smart Chain token that overrides transferFrom so that, while the trans flag is false, only transfers sent by the deployer, to the deployer, or from the pair created in the constructor are allowed. A holder selling through a router calls transferFrom with themselves as sender, so the sale reverts until an account with MINTER_ROLE calls setTrans(true). The same role can mint without a cap, and renounceOwnership and lockLiquidity only emit events.
De.Fi's REKT database lists CMOON as an Exit Scam/Honeypot dated 2021-05-24; no loss figure is given.
How it happened
- The constructor starts with sells closed and gives the deployer every role:
trans = false;,_setupRole(MINTER_ROLE, msg.sender);, and mints1000000000000 * 10 ** decimals()to the deployer. It also creates the token's pair with the router'screatePairand stores it asuniswapV2Pair. transferFromis overridden with a gate:require (trans || moi == sender || moi == recipient || sender == UNI);wheremoiis the deployer andUNIis the pair.- A router sale calls
transferFrom(holder, pair, amount). Withtransfalse, the holder is notmoi, the recipient is the pair rather thanmoi, and the sender is not the pair, so therequirereverts. A buy moves tokens from the pair (sender == UNI), so it passes. setTrans(bool value)is gated byhasRole(MINTER_ROLE, msg.sender), so the role holder alone decides whether ordinary holders can sell. The plaintransferfunction is not overridden, so a direct wallet-to-wallettransferis not covered by this gate; only thetransferFrompath used by routers is.- Other powers in the same contract:
pause()/unpause()(PAUSER_ROLE) stop all transfers through_beforeTokenTransfer ... whenNotPaused, andpiocher(address to, uint256 amount)lets aMINTER_ROLEholder mint any amount. renounceOwnership()only runsemit OwnershipRenounced(address(0), address(this));andlockLiquidity()only runsemit liquidityLocked(uniswapV2Pair, address(0));; neither changes any role or state.- What the code allows is the above. What happened is only that De.Fi's REKT database lists CMOON as a honeypot; no transaction was opened showing
setTrans, minting, a failed sale or a loss.
Protocol details
Build your security review skills
Work through hands-on labs covering real exploit mechanics, review techniques, and defensive patterns.