> ## 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](https://docs.validationcloud.io/nodeapi/about/billing.md) and each notification delivered on the subscription will use `10` Compute Units regardless of size.

***

## **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, newPendingTransactions). 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.
* **newPendingTransactions** - Returns the hash of each transaction added to the node's pending pool.

`data - object -` (Optional) - Arguments such as an address, multiple addresses, and topics. Only logs that match the address filter (any one of the listed addresses) and the topic filter are returned.

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

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

## 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](https://docs.validationcloud.io/nodeapi/cronos/execution-api/eth_unsubscribe.md).

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

//Example (newHeads)
{
  "jsonrpc": "2.0",
  "method": "eth_subscription",
  "params": {
    "subscription": "0x103847e3c719e3a67e625f64eb104f4c",
    "result": {
      "number": "0x688bdf3",
      "hash": "0x2b8d313cfe300bd759cfc636cd0deec4c1e9dd32314445ee16382032fd77acb5",
      "parentHash": "0x000df2be0148aa718da9a5d2e58a1c85ac4349ad86bed3ae456ee85e69b0b953",
      "timestamp": "0x6b11593b",
      "gasLimit": "0x0",
      "gasUsed": "0x0",
      "baseFeePerGas": "0x574fbde600",
      "miner": "0xF0847B3207b452248455c3ce5703a1831E4f5Cf1",
      "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
      "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
    }
  }
}
```

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


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