Skip to main content
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"
}
PropertyTypeDescription
NamestringUnique identifier (used in rule references)
FunctionSignaturestringMust exactly match contract function signature
EncodedValuesstringComma-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)"
}
PropertyTypeDescription
NamestringUnique identifier
AddressaddressExternal contract address (checksummed)
FunctionstringFunction signature to call
ReturnTypestringReturn type (supported Solidity types)
ValuesToPassstringComma-separated parameters (can reference calling function params or literals)
MappedTrackerKeyValuesstringKeys for mapped tracker operations
CallingFunctionstringAssociated calling function
Reference in rules: FC:YourForeignCallName

Trackers

Persistent on-chain state variables. See Trackers for detailed explanation.
{
  "Name": "totalSupply",
  "Type": "uint256",
  "InitialValue": 0
}
PropertyTypeDescription
NamestringUnique identifier
TypestringData type
InitialValuestring | arrayStarting 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]
}
PropertyTypeDescription
NamestringUnique identifier
KeyTypestringType of keys
ValueTypestringType of values
InitialKeysarrayStarting keys (must be unique)
InitialValuesarrayStarting 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
}
PropertyTypeDescription
NamestringRule name (optional)
DescriptionstringRule description (optional)
ConditionstringBoolean expression
PositiveEffectsarrayEffects when condition is true
NegativeEffectsarrayEffects when condition is false
CallingFunctionstringWhich calling function triggers this rule
OrdernumberExecution 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:
CategoryOperators
LogicalAND, 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.
I