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

# Get the opcode traces for a historical transaction on the network with the given transaction ID or hash

> Re-executes a transaction and returns a result containing detailed information for the execution,
including all values from the {@code stack}, {@code memory} and {@code storage}
and the entire trace of opcodes that were executed during the replay.

Note that to provide the output, the transaction needs to be re-executed on the EVM,
which may take a significant amount of time to complete if stack and memory information is requested.




## OpenAPI

````yaml /openapi.yaml get /api/v1/contracts/results/{transactionIdOrHash}/opcodes
openapi: 3.0.3
info:
  title: Mirror Node REST API
  version: 0.154.0
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  description: >-
    The REST API offers the ability to query transactions and entity information
    from a mirror node.


    Base url: [/api/v1](/api/v1)


    OpenAPI Spec: [/api/v1/docs/openapi.yml](/api/v1/docs/openapi.yml)
  contact:
    name: Mirror Node Team
    email: mirrornode@hedera.com
    url: https://github.com/hiero-ledger/hiero-mirror-node
servers:
  - description: Hedera Mainnet Mirror Node
    url: https://mainnet.mirrornode.hedera.com
  - description: The production REST API servers
    url: '{scheme}://{network}.mirrornode.hedera.com'
    variables:
      scheme:
        default: https
        description: The URI scheme
        enum:
          - http
          - https
      network:
        default: testnet
        description: The Hedera network in use
        enum:
          - mainnet-public
          - mainnet
          - previewnet
          - testnet
security: []
tags:
  - name: accounts
    description: >-
      The accounts object represents the information associated with an account
      entity and returns a list of account information.The accounts list
      endpoint is cached and not updated as frequently as the account lookup by
      a specific ID endpoint.
    externalDocs:
      url: >-
        https://docs.hedera.com/guides/docs/mirror-node-api/cryptocurrency-api#accounts
  - name: balances
    description: >-
      The balance object represents the balance of accounts on the Hedera
      network.
    externalDocs:
      url: >-
        https://docs.hedera.com/guides/docs/mirror-node-api/cryptocurrency-api#balances
  - name: contracts
    description: >-
      The contracts objects represents the information associated with contract
      entities.The contracts list endpoint is cached and not updated as
      frequently as the contract lookup by a specific ID endpoint.
  - name: schedules
    description: >-
      The schedules object represents the information associated with a schedule
      entity.The schedules list endpoints is cached and not updated as
      frequently as the schedule lookup by a specific ID endpoint.
  - name: transactions
    description: >-
      The transaction object represents the transactions processed on the Hedera
      network.
    externalDocs:
      url: >-
        https://docs.hedera.com/guides/docs/mirror-node-api/cryptocurrency-api#transactions
  - name: topics
    description: >-
      The topics object represents the information associated with a topic
      entity and returns topic messages information.
    externalDocs:
      url: >-
        https://docs.hedera.com/guides/docs/mirror-node-api/cryptocurrency-api#topic-messages
  - name: tokens
    description: >-
      The tokens object represents the information associated with a token
      entity and returns a list of token information.The tokens list endpoint is
      cached and not updated as frequently as the token lookup by a specific ID.
externalDocs:
  description: REST API Docs
  url: https://docs.hedera.com/guides/docs/mirror-node-api/cryptocurrency-api
paths:
  /api/v1/contracts/results/{transactionIdOrHash}/opcodes:
    get:
      tags:
        - contracts
      summary: >-
        Get the opcode traces for a historical transaction on the network with
        the given transaction ID or hash
      description: >
        Re-executes a transaction and returns a result containing detailed
        information for the execution,

        including all values from the {@code stack}, {@code memory} and {@code
        storage}

        and the entire trace of opcodes that were executed during the replay.


        Note that to provide the output, the transaction needs to be re-executed
        on the EVM,

        which may take a significant amount of time to complete if stack and
        memory information is requested.
      operationId: getContractOpcodes
      parameters:
        - $ref: '#/components/parameters/transactionIdOrEthHashPathParam'
        - $ref: '#/components/parameters/stack'
        - $ref: '#/components/parameters/memory'
        - $ref: '#/components/parameters/storage'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpcodesResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Transaction or record file not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  parameters:
    transactionIdOrEthHashPathParam:
      name: transactionIdOrHash
      in: path
      schema:
        pattern: >-
          ^(0x)?[A-Fa-f0-9]{64}|(\d{1,10})\.(\d{1,10})\.(\d{1,10})-(\d{1,19})-(\d{1,9})$
        type: string
      required: true
      description: Transaction Id or a 32 byte hash with optional 0x prefix
      examples:
        transactionId:
          value: 0.0.10-1234567890-000000000
        transactionHash:
          value: ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
        transactionHashWith0xPrefix:
          value: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
    stack:
      name: stack
      description: >-
        If provided and set to false, stack information will not be included in
        the response
      in: query
      example: true
      schema:
        type: boolean
        default: true
    memory:
      name: memory
      description: >-
        If provided and set to true, memory information will be included in the
        response
      in: query
      example: false
      schema:
        type: boolean
        default: false
    storage:
      name: storage
      description: >-
        If provided and set to true, storage information will be included in the
        response
      in: query
      example: false
      schema:
        type: boolean
        default: false
  schemas:
    OpcodesResponse:
      type: object
      required:
        - address
        - contract_id
        - failed
        - gas
        - opcodes
        - return_value
      properties:
        address:
          description: >
            The address of the transaction recipient in hex.

            Zero address is set for transactions without a recipient (e.g.,
            contract create)
          type: string
          format: binary
        contract_id:
          $ref: '#/components/schemas/EntityId'
        failed:
          description: Whether the transaction failed to be completely processed.
          type: boolean
        gas:
          description: The gas used in tinybars
          type: integer
          format: int64
        opcodes:
          description: The logs produced by the opcode logger
          type: array
          items:
            $ref: '#/components/schemas/Opcode'
        return_value:
          description: The returned data from the transaction in hex
          type: string
          format: binary
    Error:
      type: object
      properties:
        _status:
          type: object
          properties:
            messages:
              type: array
              items:
                type: object
                properties:
                  data:
                    description: Error message in hexadecimal
                    example: '0x3000'
                    format: binary
                    nullable: true
                    pattern: ^0x[0-9a-fA-F]+$
                    type: string
                  detail:
                    description: Detailed error message
                    example: Generic detailed error message
                    nullable: true
                    type: string
                  message:
                    description: Error message
                    example: Generic error message
                    nullable: false
                    type: string
    EntityId:
      type: string
      description: Network entity ID in the format of `shard.realm.num`
      pattern: ^\d{1,10}\.\d{1,10}\.\d{1,10}$
      example: 0.0.2
      nullable: true
    Opcode:
      description: Represents a struct/opcode log entry in a trace
      type: object
      required:
        - depth
        - gas
        - gas_cost
        - memory
        - op
        - pc
        - stack
        - storage
      properties:
        depth:
          description: The current call depth
          type: integer
          format: int32
        gas:
          description: The remaining gas
          type: integer
          format: int64
        gas_cost:
          description: The cost for executing op
          type: integer
          format: int64
        memory:
          description: The EVM memory with items in hex
          type: array
          items:
            type: string
            format: binary
          nullable: true
        op:
          description: The opcode to execute
          type: string
        pc:
          description: The program counter
          type: integer
          format: int32
        reason:
          description: The revert reason in hex
          type: string
          format: binary
          nullable: true
        stack:
          description: The EVM stack with items in hex
          type: array
          items:
            type: string
            format: binary
          nullable: true
        storage:
          description: >-
            The storage slots (keys and values in hex) of the current contract
            which is read from and written to
          type: object
          additionalProperties:
            type: string
            format: binary
          nullable: true

````