Block Reference
COMPARE
PLC Family
TYPE 0x0641 · PLC FAMILY

COMPARE

Flexible comparator block. Compares the transaction input_amount against one or two reference values using a specified comparison operator. Supports equality, inequality, ordering, and range checks. No Tapscript equivalent exists.

PLC Invertible
COMPARE input_amt OP value_b EQ NEQ GT LT GTE LTE IN_RANGE operator(input_amount, value_b [, value_c]) → SATISFIED / UNSATISFIED
FieldData TypeSizeSideDescription
operatorNUMERIC1-4 BConditionsComparison operator code (NUMERIC[0])
value_bNUMERIC1-4 BConditionsPrimary comparison value (NUMERIC[1])
value_cNUMERIC1-4 BConditionsUpper bound for IN_RANGE operator (NUMERIC[2], optional)

value_c is only required when operator is IN_RANGE (0x07). The input_amount comes from the evaluation context.

CodeNameOperation
0x01EQinput_amount == value_b
0x02NEQinput_amount != value_b
0x03GTinput_amount > value_b
0x04LTinput_amount < value_b
0x05GTEinput_amount ≥ value_b
0x06LTEinput_amount ≤ value_b
0x07IN_RANGEvalue_b ≤ input_amount ≤ value_c

Example with IN_RANGE operator (3 NUMERIC fields):

0x0641 0 3 NUMERIC · 3B NUMERIC · 8B NUMERIC · 8B Conditions = 27 bytes
0x0641 0 0 Witness = 4 bytes (empty block)
Total (IN_RANGE) 31 bytes
1.Read operator (NUMERIC[0]) and value_b (NUMERIC[1]). If fewer than 2 NUMERIC fields → ERROR
2.If operator is unknown (not 0x01-0x07) → ERROR
3.If operator is IN_RANGE (0x07): read value_c (NUMERIC[2]). If missing → ERROR
4.Apply operator to input_amount vs value_b (and value_c for IN_RANGE)
5.If comparison is true → SATISFIED
6.If comparison is false → UNSATISFIED
ConditionResult
Fewer than 2 NUMERIC fieldsERROR
Unknown operator codeERROR
IN_RANGE operator with missing value_cERROR
Comparison evaluates to falseUNSATISFIED
Comparison evaluates to trueSATISFIED
Conditions (IN_RANGE: 1000 ≤ amount ≤ 50000)
{
  "type": "COMPARE",
  "inverted": false,
  "fields": [
    { "type": "NUMERIC", "value": 7 },
    { "type": "NUMERIC", "value": 1000 },
    { "type": "NUMERIC", "value": 50000 }
  ]
}

This creates a range check ensuring the input amount is between 1,000 and 50,000 satoshis inclusive. Operator 7 = IN_RANGE.

operator=GTE (0x05), value_b=10000

input_amount=5000: 5000 ≥ 10000 = false → UNSATISFIED
input_amount=10000: 10000 ≥ 10000 = true → SATISFIED
input_amount=50000: 50000 ≥ 10000 = true → SATISFIED

operator=IN_RANGE (0x07), value_b=1000, value_c=5000

input_amount=500: 1000 ≤ 500 ≤ 5000 = false → UNSATISFIED
input_amount=3000: 1000 ≤ 3000 ≤ 5000 = true → SATISFIED
input_amount=6000: 1000 ≤ 6000 ≤ 5000 = false → UNSATISFIED
Amount-Gated Spending
Enforce minimum or maximum transaction amounts at the covenant level. A UTXO can require that spends exceed a minimum value (GT/GTE) or stay below a ceiling (LT/LTE), creating on-chain spending policies.
Conditional Path Selection
Different covenant paths can use different COMPARE operators to create amount-based routing. Small amounts take one path (LT), large amounts take another (GTE), enabling tiered processing.
Range Validation
IN_RANGE ensures transaction amounts fall within acceptable bounds. Useful for fee enforcement, deposit limits, or ensuring outputs stay within protocol-defined value ranges.
← COUNTER_UP SEQUENCER →