Skip to main content

bsv.Opcode

scrypt-ts / bsv / Opcode

Class: Opcode

bsv.Opcode

Opcode class, representing opcodes used in Bitcoin Script

Param

Table of contents

Constructors

Properties

Constructors

constructor

new Opcode(op_code)

Parameters

NameType
op_codenumber

Defined in

node_modules/bsv/index.d.ts:603

Properties

OP_0

Static OP_0: number

An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)

Opcode

Hex

Input

Nothing

Output

empty

Static

Defined in

node_modules/bsv/index.d.ts:29


OP_0NOTEQUAL

Static OP_0NOTEQUAL: number

Defined in

node_modules/bsv/index.d.ts:547


OP_1

Static OP_1: number

The number 1 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

1

Static

Defined in

node_modules/bsv/index.d.ts:92


OP_10

Static OP_10: number

The number in the word name 10 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

10

Static

Defined in

node_modules/bsv/index.d.ts:173


OP_11

Static OP_11: number

The number in the word name 11 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

11

Static

Defined in

node_modules/bsv/index.d.ts:182


OP_12

Static OP_12: number

The number in the word name 12 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

12

Static

Defined in

node_modules/bsv/index.d.ts:191


OP_13

Static OP_13: number

The number in the word name 13 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

13

Static

Defined in

node_modules/bsv/index.d.ts:200


OP_14

Static OP_14: number

The number in the word name 14 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

14

Static

Defined in

node_modules/bsv/index.d.ts:209


OP_15

Static OP_15: number

The number in the word name 15 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

15

Static

Defined in

node_modules/bsv/index.d.ts:218


OP_16

Static OP_16: number

The number in the word name 16 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

16

Static

Defined in

node_modules/bsv/index.d.ts:227


OP_1ADD

Static OP_1ADD: number

Defined in

node_modules/bsv/index.d.ts:540


OP_1NEGATE

Static OP_1NEGATE: number

The number -1 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

-1

Static

Defined in

node_modules/bsv/index.d.ts:65


OP_1SUB

Static OP_1SUB: number

Defined in

node_modules/bsv/index.d.ts:541


OP_2

Static OP_2: number

The number in the word name 2 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

2

Static

Defined in

node_modules/bsv/index.d.ts:101


OP_2DIV

Static OP_2DIV: number

Defined in

node_modules/bsv/index.d.ts:543


OP_2DROP

Static OP_2DROP: number

Removes the top two stack items.

Opcode

Hex

Input

x1 x2

Output

Nothing

Static

Defined in

node_modules/bsv/index.d.ts:376


OP_2DUP

Static OP_2DUP: number

Duplicates the top two stack items.

Opcode

Hex

Input

x1 x2

Output

x1 x2 x1 x2

Static

Defined in

node_modules/bsv/index.d.ts:385


OP_2MUL

Static OP_2MUL: number

Defined in

node_modules/bsv/index.d.ts:542


OP_2OVER

Static OP_2OVER: number

Copies the pair of items two spaces back in the stack to the front.

Opcode

Hex

Input

x1 x2 x3 x4

Output

x1 x2 x3 x4 x1 x2

Static

Defined in

node_modules/bsv/index.d.ts:403


OP_2ROT

Static OP_2ROT: number

The fifth and sixth items back are moved to the top of the stack.

Opcode

Hex

Input

x1 x2 x3 x4 x5 x6

Output

x3 x4 x5 x6 x1 x2

Static

Defined in

node_modules/bsv/index.d.ts:412


OP_2SWAP

Static OP_2SWAP: number

Swaps the top two pairs of items.

Opcode

Hex

Input

x1 x2 x3 x4

Output

x3 x4 x1 x2

Static

Defined in

node_modules/bsv/index.d.ts:421


OP_3

Static OP_3: number

The number in the word name 3 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

3

Static

Defined in

node_modules/bsv/index.d.ts:110


OP_3DUP

Static OP_3DUP: number

Duplicates the top three stack items.

Opcode

Hex

Input

x1 x2 x3

Output

x1 x2 x3 x1 x2 x3

Static

Defined in

node_modules/bsv/index.d.ts:394


OP_4

Static OP_4: number

The number in the word name 4 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

4

Static

Defined in

node_modules/bsv/index.d.ts:119


OP_5

Static OP_5: number

The number in the word name 5 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

5

Static

Defined in

node_modules/bsv/index.d.ts:128


OP_6

Static OP_6: number

The number in the word name 6 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

6

Static

Defined in

node_modules/bsv/index.d.ts:137


OP_7

Static OP_7: number

The number in the word name 7 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

7

Static

Defined in

node_modules/bsv/index.d.ts:146


OP_8

Static OP_8: number

The number in the word name 8 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

8

Static

Defined in

node_modules/bsv/index.d.ts:155


OP_9

Static OP_9: number

The number in the word name 9 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

9

Static

Defined in

node_modules/bsv/index.d.ts:164


OP_ABS

Static OP_ABS: number

Defined in

node_modules/bsv/index.d.ts:545


OP_ADD

Static OP_ADD: number

Defined in

node_modules/bsv/index.d.ts:549


OP_AND

Static OP_AND: number

Defined in

node_modules/bsv/index.d.ts:531


OP_BIN2NUM

Static OP_BIN2NUM: number

Defined in

node_modules/bsv/index.d.ts:526


OP_BOOLAND

Static OP_BOOLAND: number

Defined in

node_modules/bsv/index.d.ts:557


OP_BOOLOR

Static OP_BOOLOR: number

Defined in

node_modules/bsv/index.d.ts:558


OP_CAT

Static OP_CAT: number

Defined in

node_modules/bsv/index.d.ts:523


OP_CHECKLOCKTIMEVERIFY

Static OP_CHECKLOCKTIMEVERIFY: number

Defined in

node_modules/bsv/index.d.ts:583


OP_CHECKMULTISIG

Static OP_CHECKMULTISIG: number

Defined in

node_modules/bsv/index.d.ts:580


OP_CHECKMULTISIGVERIFY

Static OP_CHECKMULTISIGVERIFY: number

Defined in

node_modules/bsv/index.d.ts:581


OP_CHECKSEQUENCEVERIFY

Static OP_CHECKSEQUENCEVERIFY: number

Defined in

node_modules/bsv/index.d.ts:584


OP_CHECKSIG

Static OP_CHECKSIG: number

Defined in

node_modules/bsv/index.d.ts:578


OP_CHECKSIGVERIFY

Static OP_CHECKSIGVERIFY: number

Defined in

node_modules/bsv/index.d.ts:579


OP_CODESEPARATOR

Static OP_CODESEPARATOR: number

Defined in

node_modules/bsv/index.d.ts:577


OP_DEPTH

Static OP_DEPTH: number

Counts the number of stack items onto the stack and places the value on the top

Opcode

Hex

Input

Nothing

Output

Stack size

Static

Defined in

node_modules/bsv/index.d.ts:439


OP_DIV

Static OP_DIV: number

Defined in

node_modules/bsv/index.d.ts:552


OP_DROP

Static OP_DROP: number

Removes the top stack item.

Opcode

Hex

Input

x

Output

Nothing

Static

Defined in

node_modules/bsv/index.d.ts:448


OP_DUP

Static OP_DUP: number

Removes the top stack item.

Opcode

Hex

Input

x

Output

x x

Static

Defined in

node_modules/bsv/index.d.ts:457


OP_ELSE

Static OP_ELSE: number

If the preceding IF or NOTIF check was not valid then statement 2 is executed.

Opcode

Hex

Example

`[expression] IF
[statement 1]
ELSE
[statement 2]
ENDIF`

Static

Defined in

node_modules/bsv/index.d.ts:312


OP_ENDIF

Static OP_ENDIF: number

Ends an if/else block. All blocks must end, or the transaction is invalid. An OP_ENDIF without a prior matching OP_IF or OP_NOTIF is also invalid.

Opcode

Hex

Example

`[expression] IF
[statement 1]
ELSE
[statement 2]
ENDIF`

Static

Defined in

node_modules/bsv/index.d.ts:325


OP_EQUAL

Static OP_EQUAL: number

Defined in

node_modules/bsv/index.d.ts:534


OP_EQUALVERIFY

Static OP_EQUALVERIFY: number

Defined in

node_modules/bsv/index.d.ts:535


OP_FROMALTSTACK

Static OP_FROMALTSTACK: number

Puts the input onto the top of the main stack. Removes it from the alt stack.

Opcode

Hex

Input

(alt)x1

Output

x1

Static

Defined in

node_modules/bsv/index.d.ts:367


OP_GREATERTHAN

Static OP_GREATERTHAN: number

Defined in

node_modules/bsv/index.d.ts:563


OP_GREATERTHANOREQUAL

Static OP_GREATERTHANOREQUAL: number

Defined in

node_modules/bsv/index.d.ts:565


OP_HASH160

Static OP_HASH160: number

Defined in

node_modules/bsv/index.d.ts:575


OP_HASH256

Static OP_HASH256: number

Defined in

node_modules/bsv/index.d.ts:576


OP_IF

Static OP_IF: number

If the top stack value is TRUE, statement 1 is executed. If the top stack value is FALSE and ELSE is used, statement 2 is executed. If ELSE is NOT used, the script jumps to ENDIF. The top stack value is removed.

Opcode

Hex

Example

`[expression] IF
[statement 1]
ENDIF`
OR
`[expression] IF
[statement 1]
ELSE
[statement 2]
ENDIF`

Static

Defined in

node_modules/bsv/index.d.ts:266


OP_IFDUP

Static OP_IFDUP: number

If the top stack value is not 0, duplicate it.

Opcode

Hex

Input

x

Output

x / x x

Static

Defined in

node_modules/bsv/index.d.ts:430


OP_INVALIDOPCODE

Static OP_INVALIDOPCODE: number

Defined in

node_modules/bsv/index.d.ts:601


OP_INVERT

Static OP_INVERT: number

Defined in

node_modules/bsv/index.d.ts:530


OP_LESSTHAN

Static OP_LESSTHAN: number

Defined in

node_modules/bsv/index.d.ts:562


OP_LESSTHANOREQUAL

Static OP_LESSTHANOREQUAL: number

Defined in

node_modules/bsv/index.d.ts:564


OP_LSHIFT

Static OP_LSHIFT: number

Defined in

node_modules/bsv/index.d.ts:554


OP_MAX

Static OP_MAX: number

Defined in

node_modules/bsv/index.d.ts:567


OP_MIN

Static OP_MIN: number

Defined in

node_modules/bsv/index.d.ts:566


OP_MOD

Static OP_MOD: number

Defined in

node_modules/bsv/index.d.ts:553


OP_MUL

Static OP_MUL: number

Defined in

node_modules/bsv/index.d.ts:551


OP_NEGATE

Static OP_NEGATE: number

Defined in

node_modules/bsv/index.d.ts:544


OP_NIP

Static OP_NIP: number

Removes the second-to-top stack item.

Opcode

Hex

Input

x1 x2

Output

x2

Static

Defined in

node_modules/bsv/index.d.ts:466


OP_NOP

Static OP_NOP: number

Does nothing.

Opcode

Hex

Input

Nothing

Output

Nothing

Static

Defined in

node_modules/bsv/index.d.ts:237


OP_NOP1

Static OP_NOP1: number

Defined in

node_modules/bsv/index.d.ts:587


OP_NOP10

Static OP_NOP10: number

Defined in

node_modules/bsv/index.d.ts:596


OP_NOP2

Static OP_NOP2: number

Defined in

node_modules/bsv/index.d.ts:588


OP_NOP3

Static OP_NOP3: number

Defined in

node_modules/bsv/index.d.ts:589


OP_NOP4

Static OP_NOP4: number

Defined in

node_modules/bsv/index.d.ts:590


OP_NOP5

Static OP_NOP5: number

Defined in

node_modules/bsv/index.d.ts:591


OP_NOP6

Static OP_NOP6: number

Defined in

node_modules/bsv/index.d.ts:592


OP_NOP7

Static OP_NOP7: number

Defined in

node_modules/bsv/index.d.ts:593


OP_NOP8

Static OP_NOP8: number

Defined in

node_modules/bsv/index.d.ts:594


OP_NOP9

Static OP_NOP9: number

Defined in

node_modules/bsv/index.d.ts:595


OP_NOT

Static OP_NOT: number

Defined in

node_modules/bsv/index.d.ts:546


OP_NOTIF

Static OP_NOTIF: number

If the top stack value is FALSE, statement 1 is executed. If the top stack value is TRUE and ELSE is used, statement 2 is executed. If ELSE is NOT used, the script jumps to ENDIF. The top stack value is removed.

Opcode

Hex

Example

`[expression] NOTIF
[statement 1]
ENDIF`
OR
`[expression] NOTIF
[statement 1]
ELSE
[statement 2]
ENDIF`

Static

Defined in

node_modules/bsv/index.d.ts:285


OP_NUM2BIN

Static OP_NUM2BIN: number

Defined in

node_modules/bsv/index.d.ts:525


OP_NUMEQUAL

Static OP_NUMEQUAL: number

Defined in

node_modules/bsv/index.d.ts:559


OP_NUMEQUALVERIFY

Static OP_NUMEQUALVERIFY: number

Defined in

node_modules/bsv/index.d.ts:560


OP_NUMNOTEQUAL

Static OP_NUMNOTEQUAL: number

Defined in

node_modules/bsv/index.d.ts:561


OP_OR

Static OP_OR: number

Defined in

node_modules/bsv/index.d.ts:532


OP_OVER

Static OP_OVER: number

Copies the second-to-top stack item to the top.

Opcode

Hex

Input

x1 x2

Output

x1 x2 x1

Static

Defined in

node_modules/bsv/index.d.ts:475


OP_PICK

Static OP_PICK: number

The item n back in the stack is copied to the top.

Opcode

Hex

Input

xn ... x2 x1 x0 {n}

Output

xn ... x2 x1 x0 xn

Static

Defined in

node_modules/bsv/index.d.ts:484


OP_PUBKEY

Static OP_PUBKEY: number

Defined in

node_modules/bsv/index.d.ts:600


OP_PUBKEYHASH

Static OP_PUBKEYHASH: number

Defined in

node_modules/bsv/index.d.ts:599


OP_PUSHDATA1

Static OP_PUSHDATA1: number

The next byte contains the number of bytes to be pushed onto the stack.

Opcode

Hex

Input

special

Output

data

Static

Defined in

node_modules/bsv/index.d.ts:38


OP_PUSHDATA2

Static OP_PUSHDATA2: number

The next two bytes contain the number of bytes to be pushed onto the stack in little endian order.

Opcode

Hex

Input

special

Output

data

Static

Defined in

node_modules/bsv/index.d.ts:47


OP_PUSHDATA4

Static OP_PUSHDATA4: number

The next four bytes contain the number of bytes to be pushed onto the stack in little endian order.

Opcode

Hex

Input

special

Output

data

Static

Defined in

node_modules/bsv/index.d.ts:56


OP_RESERVED

Static OP_RESERVED: number

Reserved words, Using an unassigned opcode makes the transaction invalid.

Opcode

Hex

Input

Nothing

Output

Nothing

Static

Defined in

node_modules/bsv/index.d.ts:74


OP_RESERVED1

Static OP_RESERVED1: number

Defined in

node_modules/bsv/index.d.ts:536


OP_RESERVED2

Static OP_RESERVED2: number

Defined in

node_modules/bsv/index.d.ts:537


OP_RETURN

Static OP_RETURN: number

OP_RETURN can also be used to create "False Return" outputs with a scriptPubKey consisting of OP_FALSE OP_RETURN followed by data. Such outputs are provably unspendable and should be given a value of zero Satoshis. These outputs can be pruned from storage in the UTXO set, reducing its size. After the Genesis upgrade in 2020 miners will be free to mine transactions containing FALSE RETURN outputs of any size.

Opcode

Hex

Input

Nothing

Output

Ends script with top value on stack as final result

Static

Defined in

node_modules/bsv/index.d.ts:346


OP_RIPEMD160

Static OP_RIPEMD160: number

Defined in

node_modules/bsv/index.d.ts:572


OP_ROLL

Static OP_ROLL: number

The item n back in the stack is copied to the top.

Opcode

Hex

Input

xn ... x2 x1 x0 {n}

Output

... x2 x1 x0 xn

Static

Defined in

node_modules/bsv/index.d.ts:493


OP_ROT

Static OP_ROT: number

The top three items on the stack are rotated to the left.

Opcode

Hex

Input

x1 x2 x3

Output

x2 x3 x1

Static

Defined in

node_modules/bsv/index.d.ts:502


OP_RSHIFT

Static OP_RSHIFT: number

Defined in

node_modules/bsv/index.d.ts:555


OP_SHA1

Static OP_SHA1: number

Defined in

node_modules/bsv/index.d.ts:573


OP_SHA256

Static OP_SHA256: number

Defined in

node_modules/bsv/index.d.ts:574


OP_SIZE

Static OP_SIZE: number

Defined in

node_modules/bsv/index.d.ts:527


OP_SPLIT

Static OP_SPLIT: number

Defined in

node_modules/bsv/index.d.ts:524


OP_SUB

Static OP_SUB: number

Defined in

node_modules/bsv/index.d.ts:550


OP_SWAP

Static OP_SWAP: number

The top two items on the stack are swapped.

Opcode

Hex

Input

x1 x2

Output

x2 x1

Static

Defined in

node_modules/bsv/index.d.ts:511


OP_TOALTSTACK

Static OP_TOALTSTACK: number

Puts the input onto the top of the alt stack. Removes it from the main stack.

Opcode

Hex

Input

x1

Output

(alt)x1

Static

Defined in

node_modules/bsv/index.d.ts:358


OP_TRUE

Static OP_TRUE: number

The number 1 is pushed onto the stack.

Opcode

Hex

Input

Nothing

Output

1

Static

Defined in

node_modules/bsv/index.d.ts:83


OP_TUCK

Static OP_TUCK: number

The item at the top of the stack is copied and inserted before the second-to-top item.

Opcode

Hex

Input

x1 x2

Output

x2 x1 x2

Static

Defined in

node_modules/bsv/index.d.ts:520


OP_VER

Static OP_VER: number

DISABLED.Puts the version of the protocol under which this transaction will be evaluated onto the stack.

Opcode

Hex

Input

Nothing

Output

Protocol version

Static

Defined in

node_modules/bsv/index.d.ts:247


OP_VERIF

Static OP_VERIF: number

DISABLED

Opcode

Hex

Static

Defined in

node_modules/bsv/index.d.ts:292


OP_VERIFY

Static OP_VERIFY: number

Marks transaction as invalid if top stack value is not true. The top stack value is removed.

Opcode

Hex

Input

True / false

Output

Nothing / fail

Static

Defined in

node_modules/bsv/index.d.ts:334


OP_VERNOTIF

Static OP_VERNOTIF: number

DISABLED

Opcode

Hex

Static

Defined in

node_modules/bsv/index.d.ts:299


OP_WITHIN

Static OP_WITHIN: number

Defined in

node_modules/bsv/index.d.ts:569


OP_XOR

Static OP_XOR: number

Defined in

node_modules/bsv/index.d.ts:533