Complete technical reference for the JSON structure used to define policies. For ready-to-use templates, see Policy Templates.
Policy Structure
{
"Policy": "string (optional)",
"Description": "string (optional)",
"PolicyType": "open" | "closed" (required),
"CallingFunctions": [...] (required),
"ForeignCalls": [...] (required),
"Trackers": [...] (required),
"MappedTrackers": [...] (required),
"Rules": [...] (required)
}
Validation Requirements
- All calling functions referenced in rules must exist in
CallingFunctions
- All foreign calls referenced in rules must exist in
ForeignCalls
- All trackers referenced in rules must exist in
Trackers
or MappedTrackers
- Foreign call names only need to be unique per calling function
CallingFunctions
Defines which smart contract functions will invoke the policy. See Calling Contracts for detailed explanation.
{
"Name": "transfer(address to, uint256 value)",
"FunctionSignature": "transfer(address to, uint256 value)",
"EncodedValues": "address to, uint256 value"
}
Property | Type | Description |
---|
Name | string | Unique identifier (used in rule references) |
FunctionSignature | string | Must exactly match contract function signature |
EncodedValues | string | Comma-separated parameters sent to Rules Engine |
Supported Types: uint256
, address
, bool
, bytes
, string
, and array variants (uint256[]
, address[]
, etc.)
EncodedValues
can include additional data beyond function parameters. Parameter names are local
to the policy and don’t need to match contract names.
ForeignCalls
External contract interactions. See Foreign Contracts for detailed explanation.
{
"Name": "GetBalance",
"Address": "0x...",
"Function": "balanceOf(address)",
"ReturnType": "uint256",
"ValuesToPass": "userAddress",
"MappedTrackerKeyValues": "",
"CallingFunction": "transfer(address,uint256)"
}
Property | Type | Description |
---|
Name | string | Unique identifier |
Address | address | External contract address (checksummed) |
Function | string | Function signature to call |
ReturnType | string | Return type (supported Solidity types) |
ValuesToPass | string | Comma-separated parameters (can reference calling function params or literals) |
MappedTrackerKeyValues | string | Keys for mapped tracker operations |
CallingFunction | string | Associated calling function |
Reference in rules: FC:YourForeignCallName
Trackers
Persistent on-chain state variables. See Trackers for detailed explanation.
{
"Name": "totalSupply",
"Type": "uint256",
"InitialValue": 0
}
Property | Type | Description |
---|
Name | string | Unique identifier |
Type | string | Data type |
InitialValue | string | array | Starting value |
Supported Types: uint256
, address
, bool
, bytes
, string
, and array variants
Reference in rules:
- Read:
TR:YourTracker
- Update:
TRU:YourTracker = value
MappedTrackers
Key-value storage for per-address or per-key state. See Trackers for detailed explanation.
{
"Name": "balances",
"KeyType": "address",
"ValueType": "uint256",
"InitialKeys": ["0x..."],
"InitialValues": [0]
}
Property | Type | Description |
---|
Name | string | Unique identifier |
KeyType | string | Type of keys |
ValueType | string | Type of values |
InitialKeys | array | Starting keys (must be unique) |
InitialValues | array | Starting values (same length as InitialKeys) |
Key Types: uint256
, address
, string
, bool
, bytes
Value Types: Same as Tracker types (including arrays)
Reference in rules:
- Read:
TR:YourMappedTracker(key)
- Update:
TRU:YourMappedTracker(key) = value
Rules
Rule definitions with conditions and effects. See Rules for detailed explanation.
{
"Name": "Transfer limit",
"Description": "Block transfers over 1000",
"Condition": "amount <= 1000",
"PositiveEffects": [],
"NegativeEffects": ["revert(\"Amount too large\")"],
"CallingFunction": "transfer(address,uint256)",
"Order": 1
}
Property | Type | Description |
---|
Name | string | Rule name (optional) |
Description | string | Rule description (optional) |
Condition | string | Boolean expression |
PositiveEffects | array | Effects when condition is true |
NegativeEffects | array | Effects when condition is false |
CallingFunction | string | Which calling function triggers this rule |
Order | number | Execution order (optional, must be unique if used) |
Condition Syntax
Available Values:
- Calling function parameters (from
EncodedValues
)
- Static values:
1000
, "admin"
, 0x...
, true
- Trackers:
TR:trackerName
- Mapped trackers:
TR:trackerName(key)
- Foreign calls:
FC:foreignCallName
- Global variables:
GV:BLOCK_TIMESTAMP
, GV:MSG_SENDER
(see Global Variables)
Operators:
Category | Operators |
---|
Logical | AND , OR , NOT |
Comparison | == , != , > , < , >= , <= |
Arithmetic | + , - , * , / |
Assignment (effects only) | = , += , -= , *= , /= |
Grouping | () |
Rules:
- Logical operators must be ALL CAPS
- Parentheses required for multiple conditions:
(a > 5) AND (b < 10)
- Cannot mix AND/OR at same level without grouping
- String literals use double quotes:
"admin"
Effects
Revert: revert("message")
or revert
Stop the transaction (32 byte message limit)
Emit: emit Event message
Emit a generic event with the message
Tracker Update:
TRU:tracker = value
TRU:tracker += value
TRU:mappedTracker(key) = value
Foreign Call: FC:ForeignCallName
Execute external contract call
If a revert effect triggers, no other effects execute.