OP_DUP is a common stack operation used to duplicate the top item of the stack. Dup, short for duplicate, is usually used when we need to do something more than once (usually verify), with a specific existing item in the stack. In P2PKH, for example, it’s used to duplicate a public key which is used twice: once in an OP_EQUALVERIFY & again in OP_CHECKSIG.
OP_Code Walkthrough
Duplicates the top-most element in the stack
Get the value (not pop) of the top stack item
Duplicate item (in binary)
Push duplicated item