<p>I don't think there is a command you can run, besides looking at <a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h" rel="nofollow noreferrer">Bitcoin's source code.</a> (look for <code>enum opcodetype</code>)</p>

<p>Note that a lot of the opcodes listed there</p>

<ul>
<li>are disabled to reduce complexity, (<code>OP_CAT</code>)</li>
<li>change meanings depending on which softforks are applied, (<code>OP_CHECKLOCKTIMEVERIFY</code> and <code>OP_NOP2</code> have the same opcode) or </li>
<li>may have no meaning in a script. (<code>OP_SMALLINTEGER</code>)</li>
</ul>

<p>To get a list of ones that can actually be used without making a script fail, you need to look at the code that <a href="https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp" rel="nofollow noreferrer">actually evaluates scripts</a>. (look for <code>Bool EvalScript</code>)</p>

<p>Here's a list of legal opcodes, as of time of writing:</p>

<pre><code>(direct push, opcode 0x01-0x4b)
OP_PUSHDATA1
OP_PUSHDATA2
OP_PUSHDATA4
OP_0-16
OP_TRUE
OP_FALSE
OP_1NEGATE
OP_CHECKLOCKTIMEVERIFY
OP_CHECKSEQUENCEVERIFY
OP_NOP
OP_NOP1-10
OP_IF
OP_NOTIF
OP_ELSE
OP_ENDIF
OP_VERIFY
OP_RETURN
OP_TOALTSTACK
OP_FROMALTSTACK
OP_2DROP
OP_2DUP
OP_3DUP
OP_2OVER
OP_2ROT
OP_2SWAP
OP_IFDUP
OP_DEPTH
OP_DROP
OP_DUP
OP_NIP
OP_OVER
OP_PICK
OP_ROLL
OP_ROT
OP_SWAP
OP_TUCK
OP_SIZE
OP_EQUAL
OP_EQUALVERIFY
OP_NUMNOTEQUAL
OP_1ADD
OP_1SUB
OP_NEGATE
OP_ABS
OP_NOT
OP_0NOTEQUAL
OP_1ADD
OP_1SUB
OP_NEGATE
OP_ABS
OP_NOT
OP_0NOTEQUAL
OP_ADD
OP_SUB
OP_BOOLAND
OP_BOOLOR
OP_NUMEQUAL
OP_NUMEQUALVERIFY
OP_NUMNOTEQUAL
OP_LESSTHAN
OP_GREATERTHAN
OP_LESSTHANOREQUAL
OP_GREATERTHANOREQUAL
OP_MIN
OP_MAX
OP_ADD
OP_SUB
OP_BOOLAND
OP_BOOLOR
OP_NUMEQUAL
OP_NUMEQUALVERIFY
OP_NUMNOTEQUAL
OP_LESSTHAN
OP_GREATERTHAN
OP_LESSTHANOREQUAL
OP_GREATERTHANOREQUAL
OP_MIN
OP_MAX
OP_WITHIN
OP_RIPEMD160
OP_SHA1
OP_SHA256
OP_HASH160
OP_HASH256
OP_CODESEPARATOR
OP_CHECKSIG
OP_CHECKSIGVERIFY
OP_CHECKMULTISIG
OP_CHECKMULTISIGVERIFY
</code></pre>

<p>Bitcoin Wiki has an <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow noreferrer">excellent page</a> on this subject, if you're trying to figure out what is possible in Bitcoin script.</p>

CC BY-SA 3.0
2017-03-10T23:37:17.483Z
Thanks for the detailed answer and links. Very helpful. (I don't have enough reputation to up-vote your answer)
Colman McMahon
CC BY-SA 3.0
2017-03-11T18:06:55.227Z
Many thanks again. Just wondering, where did you get the list of legal opcodes (without hex values)? Did you draft it yourself or is it available somewhere? It's very handy to have it cleanly formatted like that.
Colman McMahon
CC BY-SA 3.0
2017-03-11T18:12:33.407Z
@ColmanMcMahon I had a copy of interpreter.cpp. I used grep to find case statements and sed to cut it down. This didn't catch every opcode, because a few push opcodes are handled differently. As for hex values, I can add that to the listing if that's helpful to you.
Nick ODell
CC BY-SA 3.0
2017-03-11T18:45:54.597Z
Thanks. Thanks really helpful. The way you have it here is great for what I currently need (presenting opcodes on a slide). I'm just thinking of when I have to revise the list in the future.
Colman McMahon
CC BY-SA 4.0
2023-03-30T22:58:38.680Z
For version 24.x: https://github.com/bitcoin/bitcoin/blob/24.x/src/script/script.h#L69
Meglio
CC BY-SA 3.0
2017-03-10T20:08:22.440Z
2017-03-10T21:07:55.957Z
2017-03-10T21:07:55.957Z
Nick ODell
<p>This is the list of opcodes supported by Bitcoin Core v0.14.0:</p>

<p><a href="https://github.com/bitcoin/bitcoin/blob/v0.14.0/src/script/script.h#L46L187" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/v0.14.0/src/script/script.h#L46L187</a></p>

CC BY-SA 3.0
2017-03-10T23:35:22.193Z
Thanks. That appears to be the section of code from the screenshot.
Colman McMahon
CC BY-SA 3.0
2017-03-10T19:58:22.610Z
2017-03-10T19:58:22.610Z
Pieter Wuille
<p>Anyone know how / where to run</p>

<pre><code>enum optypecode
</code></pre>

<p>(or some other method) to get a list of current opcodes? Like this result...
<a href="https://i.sstatic.net/ehk1f.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ehk1f.jpg" alt="enter image description here"></a></p>

<p><a href="https://www.slideshare.net/gvrooyen/20140220-bitcoin/34-We_just_used_4_opcodesenum" rel="nofollow noreferrer">https://www.slideshare.net/gvrooyen/20140220-bitcoin/34-We_just_used_4_opcodesenum</a></p>

<script><bitcoin-core-development><opcodes>
List of current opcodes?
Colman McMahon
# List of current opcodes?

(Asked by: username_0 on 2017-03-10)

Anyone know how / where to run

```
enum optypecode

```

(or some other method) to get a list of current opcodes? Like this result...
[![enter image description here](https://i.sstatic.net/ehk1f.jpg)](https://i.sstatic.net/ehk1f.jpg)

<https://www.slideshare.net/gvrooyen/20140220-bitcoin/34-We_just_used_4_opcodesenum>

**Tags:** script, bitcoin-core-development, opcodes


---

## 2 answers

### Answer by username_3 on 2017-03-10. Score: 3 | Accepted answer

This is the list of opcodes supported by Bitcoin Core v0.14.0:

<https://github.com/bitcoin/bitcoin/blob/v0.14.0/src/script/script.h#L46L187>

> **Comments:**
> **username_0**: Thanks. That appears to be the section of code from the screenshot.  

---

### Answer by username_1 on 2017-03-10. Score: 3

I don't think there is a command you can run, besides looking at [Bitcoin's source code.](https://github.com/bitcoin/bitcoin/blob/master/src/script/script.h) (look for `enum opcodetype`)

Note that a lot of the opcodes listed there

* are disabled to reduce complexity, (`OP_CAT`)
* change meanings depending on which softforks are applied, (`OP_CHECKLOCKTIMEVERIFY` and `OP_NOP2` have the same opcode) or
* may have no meaning in a script. (`OP_SMALLINTEGER`)

To get a list of ones that can actually be used without making a script fail, you need to look at the code that [actually evaluates scripts](https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp). (look for `Bool EvalScript`)

Here's a list of legal opcodes, as of time of writing:

```
(direct push, opcode 0x01-0x4b)
OP_PUSHDATA1
OP_PUSHDATA2
OP_PUSHDATA4
OP_0-16
OP_TRUE
OP_FALSE
OP_1NEGATE
OP_CHECKLOCKTIMEVERIFY
OP_CHECKSEQUENCEVERIFY
OP_NOP
OP_NOP1-10
OP_IF
OP_NOTIF
OP_ELSE
OP_ENDIF
OP_VERIFY
OP_RETURN
OP_TOALTSTACK
OP_FROMALTSTACK
OP_2DROP
OP_2DUP
OP_3DUP
OP_2OVER
OP_2ROT
OP_2SWAP
OP_IFDUP
OP_DEPTH
OP_DROP
OP_DUP
OP_NIP
OP_OVER
OP_PICK
OP_ROLL
OP_ROT
OP_SWAP
OP_TUCK
OP_SIZE
OP_EQUAL
OP_EQUALVERIFY
OP_NUMNOTEQUAL
OP_1ADD
OP_1SUB
OP_NEGATE
OP_ABS
OP_NOT
OP_0NOTEQUAL
OP_1ADD
OP_1SUB
OP_NEGATE
OP_ABS
OP_NOT
OP_0NOTEQUAL
OP_ADD
OP_SUB
OP_BOOLAND
OP_BOOLOR
OP_NUMEQUAL
OP_NUMEQUALVERIFY
OP_NUMNOTEQUAL
OP_LESSTHAN
OP_GREATERTHAN
OP_LESSTHANOREQUAL
OP_GREATERTHANOREQUAL
OP_MIN
OP_MAX
OP_ADD
OP_SUB
OP_BOOLAND
OP_BOOLOR
OP_NUMEQUAL
OP_NUMEQUALVERIFY
OP_NUMNOTEQUAL
OP_LESSTHAN
OP_GREATERTHAN
OP_LESSTHANOREQUAL
OP_GREATERTHANOREQUAL
OP_MIN
OP_MAX
OP_WITHIN
OP_RIPEMD160
OP_SHA1
OP_SHA256
OP_HASH160
OP_HASH256
OP_CODESEPARATOR
OP_CHECKSIG
OP_CHECKSIGVERIFY
OP_CHECKMULTISIG
OP_CHECKMULTISIGVERIFY

```

Bitcoin Wiki has an [excellent page](https://en.bitcoin.it/wiki/Script) on this subject, if you're trying to figure out what is possible in Bitcoin script.

> **Comments:**
> **username_0**: Thanks for the detailed answer and links. Very helpful. (I don't have enough reputation to up-vote your answer)  
> **username_0**: Many thanks again. Just wondering, where did you get the list of legal opcodes (without hex values)? Did you draft it yourself or is it available somewhere? It's very handy to have it cleanly formatted like that.  
> **username_1**: @username_0 I had a copy of interpreter.cpp. I used grep to find case statements and sed to cut it down. This didn't catch every opcode, because a few push opcodes are handled differently. As for hex values, I can add that to the listing if that's helpful to you.  
> **username_0**: Thanks. Thanks really helpful. The way you have it here is great for what I currently need (presenting opcodes on a slide). I'm just thinking of when I have to revise the list in the future.  
> **username_2**: For version 24.x: https://github.com/bitcoin/bitcoin/blob/24.x/src/script/script.h#L69  

---

