Opcodes · stack · enabled

OP_ROLL (0x7a)

Pops n, then moves the item n places back to the top.

Verified
Stack in → out
… x … n → … … x
Since
Original Bitcoin script
Cost
Base instruction cost 100 plus bytes pushed plus the roll depth. For example, rolling a 1-byte item from depth 2 makes the OP_ROLL itself cost 103 (2025 VM limits).
Bitcoin status
Same in Bitcoin (BTC)

Example

<'a'> <'b'> <'c'> OP_2 OP_ROLL

Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.

Sources

  1. Libauth BCH_2023_05 opcodes (bch-2023-opcodes.ts)
  2. CHIP-2021-05 VM Limits: Targeted Virtual Machine Limits
  3. BCHN script interpreter (interpreter.cpp)