Opcodes · arithmetic · enabled
OP_MIN (0xa3)
Pushes the smaller of two numbers. Since May 2025 numbers may be up to 10,000 bytes long (BigInt).
Verified
- Stack in → out
- a b → min(a,b)
- Since
- Original Bitcoin script
- Cost
- Base instruction cost 100, plus the result length, plus the result length again to cover number encoding (2025 VM limits).
- Bitcoin status
- Same in Bitcoin (BTC)BTC limits arithmetic inputs to 4 bytes.
Example
<fee> <1000> OP_MIN | Step | Stack after (top on the right) | What happens |
|---|---|---|
<fee> | 1500 | Say the spender asks for a 1,500-satoshi fee. |
<1000> | 1500 1000 | The contract's cap. |
OP_MIN | 1000 | The smaller number wins: the fee is capped at 1,000. |
Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.
Where OP_MIN is used
- Contracts CashScript min() : The built-in min(a, b) compiles to OP_MIN. Contracts use it to cap fees, payouts and withdrawals.
- CHIP BigInt: High-Precision Arithmetic for Bitcoin Cash : Lets OP_MIN compare numbers up to 10,000 bytes long since May 2025.
- Upgrade May 2022: native introspection and 64-bit math : Widened script numbers to 64 bits, enough to compare satoshi amounts directly.