Documentation Index
Fetch the complete documentation index at: https://docs.x402r.org/llms.txt
Use this file to discover all available pages before exploring further.
Overview
You can create custom conditions for specialized logic beyond what the built-in conditions provide. Implement theICondition interface and follow the security rules below.
ICondition Rules
From theICondition.sol NatSpec:
- MUST NOT revert — return
falseto deny, neverrevert - Should be
vieworpure— no state-changing operations - No external calls — avoid calling other contracts to prevent reentrancy risks
- Return
trueto allow,falseto deny
false return into a ConditionNotMet revert.
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)
- Comprehensive test coverage with Forge tests
Testing
Test custom conditions with Forge:Next Steps
Conditions Overview
Review the condition system architecture.
Custom Recorders
Build custom state recorders.
