<p>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.</p>

<p>Here's the source code:</p>

<pre><code>            case OP_SIZE:
            {
                // (in -- in size)
                if (stack.size() &lt; 1)
                    return false;
                CBigNum bn(stacktop(-1).size());
                stack.push_back(bn.getvch());
            }
            break
</code></pre>

CC BY-SA 3.0
2011-12-27T01:36:47.557Z
2011-12-27T01:36:47.557Z
David Schwartz
<p>Does the <a href="https://en.bitcoin.it/wiki/Script#Splice" rel="nofollow">OP_SIZE</a> operation in <a href="https://en.bitcoin.it/wiki/Script" rel="nofollow">Script</a> push one item onto the stack (length of the string), or two (string and its length)?</p>

<development><protocol><script>
Script - OP_SIZE
ThePiachu
# Script - OP_SIZE

(Asked by: username_0 on 2011-12-26)

Does the [OP\_SIZE](https://en.bitcoin.it/wiki/Script#Splice) operation in [Script](https://en.bitcoin.it/wiki/Script) push one item onto the stack (length of the string), or two (string and its length)?

**Tags:** development, protocol, script


---

## 1 answers

### Answer by username_1 on 2011-12-27. Score: 3 | Accepted answer

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());
                stack.push_back(bn.getvch());
            }
            break

```


---

