> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Bytecode.validate

> Validate bytecode structure for incomplete PUSH instructions

<Card title="Try it Live" icon="play" href="https://playground.tevm.sh?example=primitives/bytecode.ts">
  Run Bytecode examples in the interactive playground
</Card>

<Tabs>
  <Tab title="C">
    ## `bytecode_t bytecode_init(const uint8_t* code, size_t code_len)`

    Validation happens during initialization. Invalid bytecode returns null.

    ```c theme={null}
    #include "voltaire.h"

    // Valid bytecode
    uint8_t code[] = {0x60, 0x01};
    bytecode_t bc = bytecode_init(code, 2);
    if (bc == NULL) {
        // Invalid bytecode
    }
    bytecode_free(bc);

    // Invalid bytecode (PUSH1 with no data)
    uint8_t invalid[] = {0x60};
    bytecode_t bc_invalid = bytecode_init(invalid, 1);
    if (bc_invalid == NULL) {
        // Invalid bytecode caught
    }
    ```

    **Defined in:** [src/primitives.h](https://github.com/evmts/voltaire/blob/main/src/primitives.h)
  </Tab>
</Tabs>

## See Also

* [analyze](/primitives/bytecode/analyze) - Complete analysis including validation
