Opcodes · pila · habilitado

OP_DEPTH (0x74)

Apila el número de elementos que hay en la pila.

Verificado
Pila: entrada → salida
∅ → n
Desde
Script original de Bitcoin
Costo
Base instruction cost 100 plus bytes pushed (2025 VM limits).
Estado en Bitcoin
Igual en Bitcoin (BTC)

Ejemplo

OP_1 OP_2 OP_DEPTH OP_2 OP_NUMEQUALVERIFY OP_DROP
Paso Pila después (cima a la derecha) Qué ocurre
OP_1 1
OP_2 1 2
OP_DEPTH 1 2 2 Two items were on the stack, so it pushes 2.
OP_2 1 2 2 2
OP_NUMEQUALVERIFY 1 2 The count matched, so the script goes on.
OP_DROP 1 One true item is left, as the clean-stack rule requires.

Recórrelo opcode por opcode en Bitauth IDE, el depurador de la VM de BCH en el navegador.

Dónde se usa OP_DEPTH

  • Contratos Hand-written scripts, with OP_NUMEQUALVERIFY : A script can start with OP_DEPTH <n> OP_NUMEQUALVERIFY to reject an unlocking script that supplies the wrong number of items. CashScript does not emit OP_DEPTH; it tracks stack positions at compile time.
  • Implementación Libauth BCH VM : The reference JavaScript implementation that Bitauth IDE runs.

Fuentes

  1. Libauth BCH_2023_05 opcodes (bch-2023-opcodes.ts)