Skip to main content

The Basics

Policy Structure

A typical policy consists of:

  • Path Definitions: The location in your data hierarchy that the policy applies to
  • Rules: Conditions under which read and write operations are permitted
  • Fields: Definitions of data fields and their types (required for on-chain storage)
  • On-Chain Storage Flag: Indicates whether the data should be stored on-chain
  • Hooks: Actions that occur after a successful write operation
  • Plugins: Extensions that provide additional functionalities within policies

Basic Policy Structure Example:

{
"path": {
"rules": {
"read": "<condition>",
"write": "<condition>"
},
"fields": {
"requiredField": "String",
"optionalField": "UInt?"
},
"onchain": true | false,
"hooks": {
"onchain": {
"create": "<action>",
"update": "<action>",
"delete": "<action>"
}
}
}
}