Overview
You can create custom conditions for specialized logic beyond what the built-in conditions provide. Build against theICondition interface and follow the security rules below.
ICondition Rules
From theICondition.sol NatSpec:
- MUST NOT revert: return
falseto deny, neverrevert - Return
trueto allow,falseto deny
false return into a PreActionConditionNotMet revert. Prefer view or pure implementations to keep call sites cheap and gas predictable.
Example: TimeOfDayCondition
A condition that only allows actions during specific hours (UTC):Security Checklist
Before deploying a custom condition:- Returns
falseinstead of reverting on denial - Declared as
vieworpure - No external calls to untrusted contracts
- No state modifications
- Handles edge cases (zero address, zero amount, uninitialized payments)
- Full test coverage with Forge tests
Testing
Test custom conditions with Forge:Next Steps
Conditions Overview
Review the condition system architecture.
Custom Hooks
Build custom state hooks.
