Watch scripts

Rule Structure

See how a Watch rule is structured and what each part of a rule does.

Blnk Watch rules define how transactions are evaluated. Each rule describes a pattern to look for and what should happen when that pattern matches. Rules operate only on transactions.

They don’t monitor balances, ledgers, or identities.

If you need extra business context (e.g. KYC tier, promo code), pass it on the transaction as meta_data and reference it in the rule.

Watch scripts

Rules are written as watch scripts: plain-text files with the .ws extension. Watch loads these scripts from a designated folder (by default watch_scripts), compiles them, and turns them into the rules that run against each transaction.

When you add or change a .ws file in that folder, Watch picks up the change and updates the active rule set.

Rule anatomy

Every rule has two core parts: when (the pattern) and then (the outcome). The rest of this section walks through each piece and where to learn more.

A simple, complete rule looks like this:

rule HighValueUSD {                           # Rule name
  when amount > 4000 and currency == "USD"    # Condition

  then review                                 # Verdict
    score 0.5                                 # Score
    reason "USD transaction exceeds 4,000"    # Reason
}
PartWhat it doesExample
ruleStable identifier for the rule; use a name that describes the patternHighValueUSD
whenCondition to look for in the transaction.amount > 4000 and currency == "USD"
thenOutcome when the condition is met.review
scoreRule-level risk weight; you define the scale.0.5
reasonHuman-readable explanation for why the rule triggered; used for debugging and audits."USD transaction exceeds 4,000"

Rule syntax

Declare the rule

The name after rule must be a single identifier in camelCase or snake_case (e.g. HighValueUSD, burst_to_same_destination) and should describe the pattern or control so it’s clear in logs and audits.

rule ruleName {

}

Define the condition

Aim for one goal per rule: the condition should describe a single pattern or check. If you need to flag several different cases, use a separate rule for each so evaluation and debugging stay clear.

rule ruleName {
  when currency == "USD"
    and amount > 4000

  •••
}

Define the verdict

Set then to the outcome Watch should produce when the condition matches. This sample uses review, which flags the transaction for more scrutiny before you trust it.

rule ruleName {
  when currency == "USD"
    and amount > 4000

  then review
    •••
}

Add the score and reason

Score and reason are usually what the next part of your workflow uses: they tell you how serious the signal is and why the rule fired, so you know what to do with an alert from Watch.

rule ruleName {
  when currency == "USD"
    and amount > 4000

  then review
    score 0.5
    reason "USD transaction exceeds 4,000"
}