ADD opcode

op_add bitcoin script command

Opcodes are used in Bitcoin Scripts to represent commands or methods. Below you can find the value of the op_add code and an implementation in Python. A bitcoin script works with a stack of items. The op_code representing a method, usually takes or puts 1 or more items from the top of the stack.

OP_ADD
Integer value 147
Hex value 0x93

Python code representation as used Bitcoinlib

    def op_add(self):
        """
        Add the top 2 numbers of the stack and appends the result on the top of the stack.

        Fails if the top 2 items are not arithmetic or if there are not enough items on the stack.

        :return bool: Operation succeeded
        """

        if not self.is_arithmetic(2):
            return False
        self.append(encode_num(self.pop_as_number() + self.pop_as_number()))
        return True

Links to related method