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

# eth_subscribe

Subscribes to real-time events over WebSocket and returns a subscription ID that is attached to every notification.

This method will use `20` [Compute Units](/nodeapi/about/billing) and each notification delivered on the subscription will use `10` Compute Units regardless of size.

***

<Info>
  WebSocket connections on Hyperliquid are served by nanoreth, the HyperEVM archive client. `newHeads` and `logs` subscriptions are supported. `newPendingTransactions` is accepted but never delivers events, because nanoreth has no mempool; do not rely on it.
</Info>

## **Reference:** [**Here**](https://ethereum.org/en/developers/tutorials/using-websockets/#eth-subscribe)

## **Parameters**

`subscription name` - **string** - The type of event you want to subscribe to (newHeads, logs). This method supports the following subscription types:

* **newHeads** - Fires a notification each time a new header is appended to the chain, including chain reorganizations.
* **logs** - Returns logs that are included in new imported blocks and match the given filter criteria.

`data - object -` (Optional) - Arguments such as an address, multiple addresses, and topics. Note, only logs that are created from these addresses or match the specified topics will return logs.

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
// newHeads
params: ["newHeads"]

// logs from one contract
params: ["logs", {"address": "0x5555555555555555555555555555555555555555"}]
```

## Returns

`result - string` - Hex encoded subscription ID. This ID will be attached to all received events and can also be used to cancel the subscription using [eth\_unsubscribe](/nodeapi/hyperliquid/execution-api/eth_unsubscribe).

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
// Result
{"id":1,"result":"0x9a52eeddc2b289f985c0e23a7d8427c8","jsonrpc":"2.0"}

//Example (newHeads)
{
  "jsonrpc": "2.0",
  "method": "eth_subscription",
  "params": {
    "subscription": "0x9a52eeddc2b289f985c0e23a7d8427c8",
    "result": {
      "number": "0x2e2f25e",
      "hash": "0xfcc6c301f189ad5f3ae6d7678918c1e16268987e723be01bfd058a66559b2377",
      "parentHash": "0x6ef05b0441b71f2a57917c4603f3a246141896f11d7a1856a8a9672a28178878",
      "timestamp": "0x6ace13d8",
      "gasLimit": "0x2dc6c0",
      "gasUsed": "0x89c0c",
      "baseFeePerGas": "0x5f5e100",
      "miner": "0x0000000000000000000000000000000000000000",
      "transactionsRoot": "0xd4dc808b8a3e85d7bf8d051d7ecb896bf1b909f0ceeb231f5b774a40cadb22ae",
      "receiptsRoot": "0xefb0c21ecd3eb07f8b227b25f8248e944bfd58fe7be525bf41b268f8c72f92f1"
    }
  }
}
```

<CodeGroup>
  ```bash title="mainnet" theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  wscat -c wss://mainnet.hyperliquid.validationcloud.io/v1/wss/<YOUR_API_KEY_HERE>/evm
  {"jsonrpc":  "2.0",  "id":  1,  "method":"eth_subscribe","params":["newHeads"]}
  {"jsonrpc":"2.0","result":"0x5302037dae412a3454143512a3c7617b","id":1}
  ```
</CodeGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.