POST
/
evm
ots_hasCode
curl --request POST \
  --url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "method": "ots_hasCode",
  "params": [
    "0x5555555555555555555555555555555555555555",
    "latest"
  ],
  "id": 1
}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
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).
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

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

Shell
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
  }'

Example response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}

Check at specific block

Shell
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.

Body

application/json

Response

200 - application/json

Successful response indicating if address has code

The response is of type object.