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
- CHIP Native Introspection Opcodes : Added OP_UTXOVALUE with the other transaction introspection opcodes.
- Upgrade May 2022: native introspection and 64-bit math : Activated introspection on mainnet, with 64-bit numbers wide enough for any satoshi value.
- Contracts CashScript tx.inputs[i].value : Compiles to OP_UTXOVALUE. Covenants use it to make sure value moves where the contract says.