Rules evaluate conditional expressions and trigger effects based on the outcome.
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.
Every rule consists of:
true
or false
)true
or false
and control whether the positiveEffects
or negativeEffects
are triggered.
Supported operators include:
Type | Operators |
---|---|
Arithmetic | + , - , * , / |
Comparators | > , < , >= , <= , == |
Logical | AND , OR , ( , ) |
Expressions follow standard operator precedence rules and can use parentheses for grouping.
true
or false
. You can include multiple effects in either branch.
These can be:
createPolicy
function with a longer
revert message you will receive a SizeOverflowError
.stake(uint256 amount)
and unstake(uint256 amount)
functions. We want to create a policy that enforces that users cannot stake tokens after September 1st, and cannot unstake tokens until September 15th.
We would create two separate rules in the policy, and they would have different function signatures for the callingFunction
property:
timestamp
encoded value is not part of the function signature. This additional
variable must be passed via the modifier of the unstake
function in the smart contract itself.Refer to the Passing Additional Values to the Rules Engine section of the linked guide for more info.encodedValues
field in the rule definition. This can include values from the calling function signature, and/or other values, like in the example above.