You can create custom conditions for specialized logic beyond what the built-in conditions provide. Build against the ICondition interface and follow the security rules below.
MUST NOT revert: return false to deny, never revert
Return true to allow, false to deny
The operator converts a false return into a PreActionConditionNotMet revert. Prefer view or pure implementations to keep call sites cheap and gas predictable.
Usage, deploy via a factory and use in operator config:
// Deploy via your custom factoryconst businessHours = await timeOfDayConditionFactory.write.deploy([9, 17]);// Use in operator configconfig.capturePreActionCondition = businessHours;
Handles edge cases (zero address, zero amount, uninitialized payments)
Full test coverage with Forge tests
Custom conditions with bugs can lead to permanently locked funds (if check() always returns false) or unauthorized access (if check() always returns true). Test on Base Sepolia before mainnet deployment.
contract TimeOfDayConditionTest is Test { TimeOfDayCondition condition; function setUp() public { condition = new TimeOfDayCondition(9, 17); } function test_allowsDuringBusinessHours() public { // Set block.timestamp to 10 AM UTC vm.warp(10 * 3600); assertTrue(condition.check(paymentInfo, 0, caller, "")); } function test_deniesOutsideBusinessHours() public { // Set block.timestamp to 8 PM UTC vm.warp(20 * 3600); assertFalse(condition.check(paymentInfo, 0, caller, "")); }}