Rules
Conditional statements that evaluate expressions and trigger effects based on the outcome.
A rule is the core decision-making unit within a policy. Each rule defines a condition expression that is evaluated during a contract call—and one or more effects that are triggered based on whether that condition expression evaluates to true
or false
.
Rules are executed in the order they appear in the policy. This matters when one rule affects data (like a tracker) used by another.
Anatomy of a Rule
Every rule consists of:
- ✅ Name
- 📝 Description
- 🔍 Condition expression
An expression that must evaluate to a boolean (true
orfalse
) - 🎯 Effects when true
What happens if the condition expression evaluates to true - 🚫 Effects when false
What happens if the condition expression evaluates to false - 🔢 Execution order
Rules run sequentially—this order is defined in the policy configuration
Condition Expressions
Condition expressions are defined by a sequence of values, operators, and optional parentheses. These expressions evaluate to true
or false
and control whether the “true” or “false” effects run.
Supported operators include:
Type | Operators |
---|---|
Arithmetic | + , - , * , / |
Comparators | > , < , >= , <= , == , != |
Logical | AND , OR , NOT |
Values in an expression can come from:
- Config data — set at configuration time
- Available data - sent from the calling contract, e.g. sender, token ID, method, timestamp, balance
- Trackers — on-chain values managed by your policy
- Foreign calls — values returned by external smart contract calls
🧠 Expressions follow standard operator precedence rules and can use parentheses for grouping.
Effects
Each rule must define at least one effect that takes place if the condition expression evaluates to true
or false
. You can include multiple effects in either branch.
These can be:
revert
: cancel the transactionemit event
: emit an ethereum eventupdate tracker
: update a tracker’s valuecall external contract
: call a foreign contract