You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This page has not yet been written. If you have experience with bitcoin Script and would like to contribute, please do! You can open a PR [on the repository for this website](https://github.com/thunderbiscuit/opcode-explained).
3
+
:::info
4
+
**Opcode number:** 163
5
+
**Byte representation:**`0xa3`
6
+
**Short description:** Pop the top two items; push the smaller of the two onto the stack.
5
7
:::
8
+
9
+
`OP_MIN` compares the top two items on the stack as integers and pushes the smaller value back onto the stack. Both original items are removed, and the smaller value becomes the new top item.
10
+
11
+
### Operation
12
+
1. Pop the top item and the second item from the stack.
13
+
2. Compare the two items, and push the smaller of the two values onto the stack.
14
+
15
+
### Notes
16
+
17
+
- Both items must be valid integers. Bitcoin Script interprets byte arrays up to **4 bytes** as integers.
18
+
- An empty array (`[]`) is treated as 0 when compared.
19
+
- If there are fewer than two items on the stack when `OP_GREATERTHAN` is executed, the script will fail.
20
+
21
+
## Examples
22
+
23
+
### Example 1: Comparing two positive integers
24
+
25
+
```shell
26
+
# ASM script
27
+
OP_3 OP_2 OP_MIN
28
+
29
+
# Raw script
30
+
5352a3
31
+
32
+
# Stack (before OP_MIN)
33
+
2 # top
34
+
3
35
+
36
+
# Stack (after OP_MIN)
37
+
2 # smaller value
38
+
```
39
+
40
+
### Example 2: Comparing a positive and a negative integer
0 commit comments