How a Fee-on-Transfer ERC-20 Example Handles Burns, Treasury Fees and Exemptions

For a builder, the useful question in the MUSHROOM (SHROOM) story is what the supplied contract example actually does when tokens move. In an article published November 12, 2026, at 18:43 UTC+8, the original author presents a Solidity 0.8.28 example built with OpenZeppelin v5, alongside proposed integration tests. The article also links the token to a reported surge driven by an AI-generated acquisition story. Its example code should not be mistaken for verification of a deployed SHROOM contract or its market activity.

Follow a transfer through the example

The MushroomToken example is an ERC-20 fungible token: each unit is interchangeable with another. Its constructor mints 1 billion tokens to the deployer and sets a treasury wallet. The deployer and treasury are initially exempt from transfer fees.

For a transfer between two non-exempt addresses, the overridden _update function applies a default 1% burn and 1% treasury fee. On a transfer of 1,000 tokens, the example’s arithmetic burns 10, sends 10 to the treasury and delivers 980 to the recipient. The burn uses the zero-address path in the underlying ERC-20 implementation, reducing totalSupply; it is not a transfer to a separate “dead wallet.” Minting and burning bypass the fee calculation. A transfer is also fee-free if either its sender or recipient is exempt.

This code does not implement an automatic market buyback. It allocates a fee to the treasury, whose subsequent use is outside the transfer logic.

Check the owner’s controls

The owner can change both fee rates, replace the treasury wallet and change address exemptions. setFees caps the combined burn and treasury rates at 10%; it does not fix them at their 1% defaults. Exemptions matter as much as the headline rate because the owner can make transfers involving selected addresses fee-free. The example suggests exempting exchange infrastructure, but it does not establish that any particular pool or router was configured.

The accompanying Hardhat/Viem and Node.js node:test script specifies checks for initial supply, a taxed transfer, an exempt transfer, owner-only controls and the 10% cap. The source provides the script, not test output, an audit or evidence of production deployment. Those checks describe intended behavior, not a guarantee that the example is safe for live use.

Source: learnblockchain.cn (originally published 2026-11-12 18:43 UTC+8)

Further reading