OP_ROLL is a stack manipulation opcode that moves the nth item from the stack to the top position. The index 'n' is taken from the top of the stack, and it starts counting from 1, where 1 represents the top item. After the operation, the original stack order is preserved, with the moved item becoming the new top item.
OP_Code Walkthrough
Removes the second-to-top stack item.
pop the first item in the stack
Find the value of the n + 1 item in the stack, where n = 2
pop the stack till you get to the nth value
get the nth item in the stack
add the new items to the stack with the nth item first