> ## 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, syncing). 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.
* **syncing** - Notifies when the node starts or stops syncing.

`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": "0x0000000071727de22e5e9d8baf0edac6f37da032"}]
```

## 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/worldchain/execution-api/eth_unsubscribe.md).

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

//Example (newHeads)
{
  "jsonrpc": "2.0",
  "method": "eth_subscription",
  "params": {
    "subscription": "0x834e284c6793fa419f283588b81de2ee",
    "result": {
      "number": "0x24bd6e5",
      "hash": "0x68eeac42a516b75c248460f504937d7dbea14979890422232375bad4816a8c3f",
      "parentHash": "0xf079bf74f0de23667fb87a14ceb3dbed9e051092b2fc1e4b11fa35f9b4984581",
      "timestamp": "0x6b12a8a1",
      "gasLimit": "0x10b07600",
      "gasUsed": "0x3a7601",
      "baseFeePerGas": "0x7a120",
      "miner": "0x4200000000000000000000000000000000000011",
      "transactionsRoot": "0x53aeb9b89a164016c9be497fea630eb5c0e208c5882b116d3b712a57e6a87384",
      "receiptsRoot": "0xa1019c2762900c9dc0c87ea841a34f5d113843fe4885b25ce233a4d1329b7020"
    }
  }
}
```

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


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