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

# ots_hasCode | Hyperliquid EVM

> The ots_hasCode JSON-RPC method checks whether a specified address contains deployed contract code on the Hyperliquid EVM blockchain.

<Info>
  This method is available on Chainstack. Not all Hyperliquid methods are available on Chainstack, as the open-source node implementation does not support them yet — see [Hyperliquid methods](/docs/hyperliquid-methods) for the full availability breakdown.
</Info>

The `ots_hasCode` JSON-RPC method checks whether a specified address contains deployed contract code on the Hyperliquid EVM blockchain. This Otterscan-specific method provides a quick way to determine if an address is a smart contract or an externally owned account (EOA).

## Parameters

1. **address** (string, required): The address to check for deployed code
2. **block identifier** (string, optional): The block at which to check the code
   * Can be a block number, block hash, or one of: `"earliest"`, `"latest"`, `"pending"`
   * Defaults to `"latest"`

## Response

The method returns a boolean value indicating whether the address contains code.

### Response structure

* `true` — the address contains deployed contract code
* `false` — the address is an EOA or does not exist

## Usage example

<CodeGroup>
  ```shell Shell theme={"system"}
  curl -X POST https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
    -H "Content-Type: application/json" \
    -d '{
      "jsonrpc": "2.0",
      "method": "ots_hasCode",
      "params": ["0x5555555555555555555555555555555555555555", "latest"],
      "id": 1
    }'
  ```

  ```python Python (web3.py) theme={"system"}
  from web3 import Web3

  w3 = Web3(Web3.HTTPProvider("YOUR_CHAINSTACK_ENDPOINT"))

  # ots_hasCode is an Otterscan namespace method, so call it as a raw JSON-RPC request.
  response = w3.provider.make_request(
      "ots_hasCode",
      ["0x5555555555555555555555555555555555555555", "latest"],
  )
  print(response["result"])
  ```

  ```javascript JavaScript (ethers.js) theme={"system"}
  import { JsonRpcProvider } from "ethers";

  const provider = new JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT");

  // ots_hasCode is an Otterscan namespace method, so send it as a raw JSON-RPC request.
  const hasCode = await provider.send("ots_hasCode", [
    "0x5555555555555555555555555555555555555555",
    "latest",
  ]);
  console.log(hasCode);
  ```

  ```typescript TypeScript (viem) theme={"system"}
  import { createPublicClient, http } from "viem";

  const client = createPublicClient({
    transport: http("YOUR_CHAINSTACK_ENDPOINT"),
  });

  // ots_hasCode is an Otterscan namespace method, so issue it through the low-level request method.
  const hasCode = await client.request({
    method: "ots_hasCode" as any,
    params: ["0x5555555555555555555555555555555555555555", "latest"] as any,
  });
  console.log(hasCode);
  ```
</CodeGroup>

<Note>
  **Use your own endpoint in your code.** The code examples use a placeholder Chainstack endpoint (YOUR\_CHAINSTACK\_ENDPOINT) — replace it with your own Hyperliquid node endpoint from the [Chainstack console](https://console.chainstack.com/). The curl above uses a shared public endpoint for quick checks only; do not use it in production.
</Note>

### Example response

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
```

### Check at specific block

```shell Shell theme={"system"}
curl -X POST https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "ots_hasCode",
    "params": ["0x5555555555555555555555555555555555555555", "0x1000"],
    "id": 1
  }'
```

## Use cases

The `ots_hasCode` method is essential for:

* **Address classification**: Quickly determine if an address is a contract or EOA
* **Transaction validation**: Check if transaction targets are contracts before sending
* **Security checks**: Verify addresses before interacting with them
* **UI differentiation**: Display different interfaces for contracts vs EOAs
* **Gas estimation**: Optimize gas estimates based on target address type
* **Contract verification**: Confirm successful contract deployment
* **Historical analysis**: Check when contracts were deployed by testing different blocks
* **Wallet integration**: Warn users when sending to contracts vs regular addresses
* **Smart contract interaction**: Pre-validate addresses before calling contract methods
* **Block explorer optimization**: Efficiently categorize addresses without fetching full code

This method provides a lightweight alternative to `eth_getCode` when you only need to know if code exists, not the actual bytecode itself.


## OpenAPI

````yaml openapi/hyperliquid_node_api/hyperevm/evm_ots_has_code.json post /evm
openapi: 3.0.0
info:
  title: Hyperliquid EVM API - ots_hasCode
  version: 1.0.0
servers:
  - url: >-
      https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274
security: []
paths:
  /evm:
    post:
      summary: ots_hasCode
      description: >-
        Check if an address contains deployed contract code on Hyperliquid EVM.
        Efficiently determine if an address is a smart contract.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - jsonrpc
                - method
                - params
                - id
              properties:
                jsonrpc:
                  type: string
                  enum:
                    - '2.0'
                  default: '2.0'
                  description: JSON-RPC version
                method:
                  type: string
                  enum:
                    - ots_hasCode
                  default: ots_hasCode
                  description: The RPC method name
                params:
                  type: array
                  description: 'Parameters: [address, block identifier (optional)]'
                  default:
                    - '0x5555555555555555555555555555555555555555'
                    - latest
                id:
                  type: integer
                  default: 1
                  description: Request identifier
            example:
              jsonrpc: '2.0'
              method: ots_hasCode
              params:
                - '0x5555555555555555555555555555555555555555'
                - latest
              id: 1
      responses:
        '200':
          description: Successful response indicating if address has code
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    description: JSON-RPC version
                  id:
                    type: integer
                    description: Request identifier
                  result:
                    type: boolean
                    description: True if address has code, false otherwise
              example:
                jsonrpc: '2.0'
                id: 1
                result: true

````