Does the OP_SIZE operation in Script push one item onto the stack (length of the string), or two (string and its length)?

1 Answer 1


It pushes one item onto the stack, the size of the item on the top of the stack. The item whose size it pushes onto the stack is not consumed, it becomes the second item on the stack.

Here's the source code:

            case OP_SIZE:
                // (in -- in size)
                if (stack.size() < 1)
                    return false;
                CBigNum bn(stacktop(-1).size());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.