data.params) and runtime data from WASM oracles (data.data).
What Makes Up a Policy
Every policy deployment requires these files:| File | Purpose |
|---|---|
policy.rego | Rego policy logic — the core evaluation rules |
policy.wasm | Compiled WASM data oracle (see Writing Data Oracles) |
params_schema.json | JSON Schema defining configurable parameters |
policy_metadata.json | Human-readable policy metadata |
policy_data_metadata.json | Human-readable oracle metadata |
Data References
Your Rego policy can access three data namespaces:| Path | Source | Description |
|---|---|---|
input | Intent | The transaction intent being evaluated (from, to, value, data, chain_id, function_signature) |
data.params | PolicyClient | Configuration parameters set by the contract owner (thresholds, allowlists) |
data.data | PolicyData WASM | Runtime data returned by your WASM oracle (prices, KYC status) |
Your First Policy
Createpolicy.rego:
- Defaults to deny (
allow := false) - Allows transactions where the oracle reports no sanctions match
- Always allows transactions from the configured admin address
Using Intent Fields
Theinput object contains the Intent fields:
Using Oracle Data
Thedata.data path contains whatever your WASM oracle returned:
Parameter Schema
Createparams_schema.json to define which parameters contract owners can configure:
Metadata Files
Createpolicy_metadata.json:
policy_data_metadata.json:
Directory Structure
Organize all files into apolicy-files/ directory:
Testing Locally
Test your policy with the CLI before deploying:The
--entrypoint value must match your Rego package name + rule name. For package sanctions_check with rule allow, use sanctions_check.allow.Using Identity Data in Policies
Newton provides built-in functions for checking user identity data (KYC status, age, location) within your policies. Identity data is injected by operators from the on-chain IdentityRegistry — you only see boolean check results, never raw personal data.newton.identity.kyc.*). A generic newton.identity.get("field_name") accessor is also available for ad-hoc field access across any domain. See the Rego Syntax Guide for the full reference.
Next Steps
Deploying with CLI
Deploy your policy to IPFS and register it on-chain
Smart Contract Integration
Integrate the policy into your smart contract