Opcodes · introspection · enabled

OP_UTXOVALUE (0xc6)

Pushes the value in satoshis of the UTXO spent by input i. Fails if the index is out of range.

Verified
Stack in → out
i → sats
Cost
Base instruction cost 100 plus the byte length of the pushed result (2025 VM limits).
Bitcoin status
Not in Bitcoin (BTC)BTC has no native introspection opcodes. In Tapscript (BIP-342) this byte is an OP_SUCCESSx code reserved for future soft forks.

Example

OP_INPUTINDEX OP_UTXOVALUE <1000> OP_SUB OP_0 OP_OUTPUTVALUE OP_LESSTHANOREQUAL
Step Stack after (top on the right) What happens
OP_INPUTINDEX 0 This input's index, here 0.
OP_UTXOVALUE 100000 Say the coin it spends holds 100,000 satoshis.
<1000> 100000 1000 The most the spender may take as a fee.
OP_SUB 99000
OP_0 99000 0
OP_OUTPUTVALUE 99000 99500 Output 0 pays 99,500 satoshis.
OP_LESSTHANOREQUAL 1 Output 0 keeps all but at most 1,000 satoshis of the input, so the covenant passes.

Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.

Where OP_UTXOVALUE is used

Sources

  1. CHIP-2021-02 Native Introspection Opcodes
  2. Libauth BCH_2023_05 opcodes (bch-2023-opcodes.ts)
  3. CHIP-2021-05 VM Limits: Targeted Virtual Machine Limits