How does it work?
By hooking thetransfer and transferFrom functions of the ERC-20 contract into the Rules Engine with a policy that checks if the sender’s post-transfer balance would fall below the required minimum threshold.
Let’s break that down further.
When a user attempts to transfer tokens, the Rules Engine checks their current balance against the amount they’re trying to transfer. If completing the transfer would leave them with less than the minimum required balance (in this example, 1000 tokens), the transaction reverts. This is particularly useful for:- Vesting schedules: Lock initial airdrop amounts while allowing users to keep tokens they’ve purchased or earned
- Anti-dumping protection: Prevent recipients from immediately selling all their airdropped tokens
- Community engagement: Encourage long-term holding by requiring a minimum stake
Implementation
The policy uses a Foreign Call to check the sender’s balance before the transfer executes. You’ll need to:- Set the minimum balance threshold (e.g., 1000 tokens)
- Replace
0xTokenContractAddresswith your actual token contract address - Optionally, combine this with time-based rules to gradually reduce the lockup amount over time
Policy JSON
It’s critical that you add the rule to both the
transfer and transferFrom functions to ensure
the minimum balance requirement cannot be bypassed through allowance-based transfers.