Defining a Tracker
Standard Tracker
To add a new tracker to a policy, you’ll define:- Name (this will not be stored on-chain but is used to reference the tracker when using the SDK or the UI)
- Type
- Initial value: the tracker’s starting value.
Mapped Tracker
To add a new mapped tracker to a policy, you’ll define:- Name (this will not be stored on-chain but is used to reference the tracker when using the SDK or the UI)
- keyType the data type of the mapped tracker keys
- valueType the data type of the mapped tracker values
- initialKeys: the tracker’s initial keys.
- initialValues: the tracker’s initial values.
Reading from a Tracker
Once defined, you can reference any tracker in any expression in the policy. For example, you can use a tracker in a rule’s condition expression, or use a tracker in a tracker’s update expression (its own or another’s).Updating a Tracker
Trackers are updated by using the update tracker effect in a rule. When using this effect, you’ll provide the name of the tracker and the update expression. Updating a mapped tracker requires the name of the tracker, the key, and the update expression. For full details on how to use trackers in your policy, see our Trackers Guide.Be mindful of the ordering of your rules that use and update trackers. Trackers are updated as
rule effects, so the new value is only visible in later rules—not the one that triggered the
update. Also, if multiple rules update the same tracker, make sure it’s deliberate.