Opcodes · empalme · habilitado
OP_SIZE (0x82)
Apila la longitud en bytes del elemento superior sin eliminarlo.
Verificado
- Pila: entrada → salida
- x → x len
- Desde
- Script original de Bitcoin
- Costo
- Base instruction cost 100 plus the byte length of the pushed result (2025 VM limits).
- Estado en Bitcoin
- Igual en Bitcoin (BTC)
Ejemplo
<0x112233> OP_SIZE OP_3 OP_EQUALVERIFY | Paso | Pila después (cima a la derecha) | Qué ocurre |
|---|---|---|
<0x112233> | 112233 | |
OP_SIZE | 112233 3 | Pushes the length. The item itself stays. |
OP_3 | 112233 3 3 | |
OP_EQUALVERIFY | 112233 | The length was 3, so the script goes on with the item. |
Recórrelo opcode por opcode en Bitauth IDE, el depurador de la VM de BCH en el navegador.
Dónde se usa OP_SIZE
- Contratos CashScript .length : bytes.length compiles to OP_SIZE OP_NIP: measure, then drop the item. Contracts use it to check a preimage or an NFT commitment has the expected size.
- CHIP VM Limits: Targeted Virtual Machine Limits : Raised the largest stack item from 520 to 10,000 bytes, so OP_SIZE can now return up to 10,000.