# Compute Unit (CU) values are subject to change as we assess and adjust our pricing to better reflect usage and associated costs.

Blockdaemon's RPC API supports WebSocket connections for real-time blockchain data on supported chains. This guide covers how to connect, which methods are available, and how Compute Units (CUs) are calculated.

## Supported Chains

| Chain Group         | Chains                                                        |
|---------------------|--------------------------------------------------------------|
| Ethereum-Compatible  | Ethereum, Base, Polygon, Arbitrum, Avalanche, Optimism     |
| Solana              | Solana                                                       |
| Polkadot            | Polkadot, Kusama                                            |

## WebSocket Methods & Compute Units

Non-subscription RPC methods over web-socket connection are billed the same as regular RPC methods over HTTP.

- [Ethereum](https://docs.blockdaemon.com/reference/ethereum-compute-units)
- [Polkadot](https://docs.blockdaemon.com/reference/polkadot-compute-units)

### Ethereum-Compatible Chains

| Supported Methods                                          | Event Types | Compute Units        |
|-----------------------------------------------------------|-------------|----------------------|
| [`eth_subscribe`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#create-subscriptions)        | `logs`      | 30 CU per block      |
| `newHeads`                                               | 5 CU per message |                    |
| `newPendingTransactions`                                 | 20 CU per second |                    |
| [`eth_unsubscribe`](https://geth.ethereum.org/docs/interacting-with-geth/rpc/pubsub#cancel-subscriptions)      |             |                      |

- **Subscribe / Unsubscribe request:** 1 CU per request
- **Confirmation responses:** 1 CU
- **Event messages (e.g., `newHeads`):** CU varies by event type

The minimum charge is **1 CU** per action.

**Billing Example** – Subscribe to `eth_subscribe` with `newHeads`

| Description                                  | Count | CU per Action  | Total CU |
|----------------------------------------------|-------|----------------|----------|
| 🔼 Open WebSocket connection                 | 1     | 1 CU           | 1        |
| 🔼 Send `eth_subscribe` request             | 1     | 1 CU           | 1        |
| 🔽 Receive confirmation from node            | 1     | 1 CU           | 1        |
| 🔽 Receive `newHeads` messages               | 5     | 10 CU          | 50       |
| 🔼 Send `eth_unsubscribe` request           | 1     | 1 CU           | 1        |
| 🔽 Receive unsubscribe confirmation           | 1     | 1 CU           | 1        |
| **Total Compute Units**                       |       |                | 55 CU    |

### Solana

| Supported Methods                              | CU per Subscription | Subscribes To            | CU per Message |
|------------------------------------------------|---------------------|---------------------------|-----------------|
| [`accountSubscribe`](https://solana.com/docs/rpc/websocket/accountsubscribe)            | 1 CU                | `accountNotification`     | 5 CU            |
| [`accountUnsubscribe`](https://solana.com/docs/rpc/websocket/accountunsubscribe)        | 1 CU                |                           |                 |
| [`logsSubscribe`](https://solana.com/docs/rpc/websocket/logssubscribe)                | 1 CU                | `logsNotification`        | 5 CU            |
| [`logsUnsubscribe`](https://solana.com/docs/rpc/websocket/logsunsubscribe)            | 1 CU                |                           |                 |
| [`programSubscribe`](https://solana.com/docs/rpc/websocket/programsubscribe)          | 1 CU                | `programNotification`     | 10 CU           |
| [`programUnsubscribe`](https://solana.com/docs/rpc/websocket/programunsubscribe)      | 1 CU                |                           |                 |
| [`signatureSubscribe`](https://solana.com/docs/rpc/websocket/signaturesubscribe)      | 1 CU                | `signatureNotification`   | 5 CU            |
| [`signatureUnsubscribe`](https://solana.com/docs/rpc/websocket/signatureunsubscribe)  | 1 CU                |                           |                 |
| [`slotSubscribe`](https://solana.com/docs/rpc/websocket/slotsubscribe)                | 1 CU                | `slotNotification`        | 5 CU            |
| [`slotUnsubscribe`](https://solana.com/docs/rpc/websocket/slotunsubscribe)            | 1 CU                |                           |                 |
| [`slotsUpdatesSubscribe`](https://solana.com/docs/rpc/websocket/slotsupdatessubscribe)| 1 CU                | `slotsUpdatesNotification`| 5 CU            |
| [`slotsUpdatesUnsubscribe`](https://solana.com/docs/rpc/websocket/slotsupdatesunsubscribe)| 1 CU                |                           |                 |

**- Subscribe / Unsubscribe request:** 1 CU per request
**- Confirmation responses:** 1 CU
**- Event messages (e.g., `slotNotification`):** CU varies by event type

Each subscription type has a specific event type tied to it. For example, you send `slotSubscribe` → you’ll receive messages of type `slotNotification`.

**Billing Example** – Subscribe to `accountSubscribe` and receive `accountNotification`

| Description                             | Count | CU per Action | Total CU |
|-----------------------------------------|-------|---------------|----------|
| 🔼 Send `accountSubscribe` request      | 1     | 1 CU          | 1        |
| 🔽 Receive confirmation response         | 1     | 1 CU          | 1        |
| 🔽 Receive `accountNotification` messages| 8     | 5 CU          | 40       |
| 🔼 Send `accountUnsubscribe` request    | 1     | 1 CU          | 1        |
| 🔽 Receive unsubscribe confirmation      | 1     | 1 CU          | 1        |
| **Total Compute Units**                  |       |               | 44 CU    |

### Polkadot

| Supported Methods                               | CU per Subscription | Subscribes To               | CU per Message |
|------------------------------------------------|---------------------|-----------------------------|-----------------|
| [`beefy_subscribeJustifications`](https://polkadot.js.org/docs/substrate/rpc/#subscribejustifications-beefyversionedfinalityproof) | 1 CU                | `beefy_justifications`      | 1 CU            |
| `beefy_unsubscribeJustifications`              | 1 CU                |                             |                 |
| [`chain_subscribeFinalizedHeads`](https://polkadot.js.org/docs/substrate/rpc/#subscribefinalizedheads-header)        | 1 CU                | `chain_finalizedHead`      | 1 CU            |
| `chain_unsubscribeFinalizedHeads`              | 1 CU                |                             |                 |
| [`chain_subscribeAllHeads`](https://polkadot.js.org/docs/substrate/rpc/#subscribeallheads-header)                | 1 CU                | `chain_allHead`            | 1 CU            |
| `chain_unsubscribeAllHeads`                    | 1 CU                |                             |                 |
| [`chain_subscribeNewHeads`](https://polkadot.js.org/docs/substrate/rpc/#subscribenewheads-header)                | 1 CU                | `chain_newHead`            | 1 CU            |
| `chain_unsubscribeNewHeads`                    | 1 CU                |                             |                 |
| [`grandpa_subscribeJustifications`](https://polkadot.js.org/docs/substrate/rpc/#subscribejustifications-justificationnotification) | 1 CU                | `grandpa_justifications`  | 1 CU            |
| `grandpa_unsubscribeJustifications`            | 1 CU                |                             |                 |
| [`state_subscribeRuntimeVersion`](https://polkadot.js.org/docs/substrate/rpc/#subscriberuntimeversion-runtimeversion) | 1 CU                | `state_runtimeVersion`      | 1 CU            |
| `state_unsubscribeRuntimeVersion`              | 1 CU                |                             |                 |
| [`state_subscribeStorage`](https://polkadot.js.org/docs/substrate/rpc/#subscribestoragekeys-vecstoragekey-storagechangeset)    | 1 CU                | `state_storage`             | 5 CU            |
| `state_unsubscribeStorage`                      | 1 CU                |                             |                 |

**- Subscribe / Unsubscribe request:** 1 CU per request
**- Confirmation responses:** 1 CU
**- Event messages (e.g., `chain_newHead`):** CU varies by event type

Each subscription type has a specific event type tied to it. For example, you send `state_subscribeStorage` → you’ll receive messages of type `state_storage`.

**Billing Example** – Subscribe to `state_subscribeStorage` and receive `state_storage` notifications

| Description                             | Count | CU per Action | Total CU |
|-----------------------------------------|-------|---------------|----------|
| 🔼 Send `state_subscribeStorage` request| 1     | 1 CU          | 1        |
| 🔽 Receive confirmation response         | 1     | 1 CU          | 1        |
| 🔽 Receive `state_storage` notifications | 6     | 5 CU          | 30       |
| 🔼 Send `state_unsubscribeStorage` request| 1    | 1 CU          | 1        |
| 🔽 Receive unsubscribe confirmation      | 1     | 1 CU          | 1        |
| **Total Compute Units**                  |       |               | 34 CU    |

## How to Connect

To connect to the WebSocket endpoint, follow these steps:

1. **Authorize** your request using one of the following methods:
    
    Bearer Token
    
    ```curl
    curl --header "Authorization: Bearer YOUR_API_KEY"
    ```
    
    API Key
    
    ```curl
    curl --header "X-API-KEY: YOUR_API_KEY"
    ```

2. You'll need to **install** a WebSocket client like `wscat`, or any other tool you prefer to connect.

```undefined
    npm install -g wscat   //One-time installation
    ```

3. **Connect** to the WebSocket URL with the following URL pattern:

```undefined
    wss://svc.blockdaemon.com/:protocol/:network/native
    ```
    
    For example, for Ethereum Mainnet:
    
    ```undefined
    wscat --header "Authorization: Bearer YOUR_API_KEY" \
    -c wss://svc.blockdaemon.com/ethereum/mainnet/native
    ```

4. Once connected, you can **send and receive** messages using JSON-RPC:

JSON
    
    ```json
    // Subscribe to a WebSocket event (e.g., newHeads)
    {"jsonrpc":"2.0","method":"eth_subscribe","params":["newHeads"],"id":1}
    
    // Server responds with a subscription ID
    {"jsonrpc":"2.0","id":1,"result":"0xb544f3328760ac404b9e3a4aec6f2ec0"}
    
    // You’ll receive real-time updates as events happen
    {"jsonrpc":"2.0","method":"eth_subscription","params":{
      "subscription":"0xb544f3328760ac404b9e3a4aec6f2ec0",
      "result":{ /* event data */ }
    }}
    
    // To unsubscribe from the event stream
    {"jsonrpc":"2.0","method":"eth_unsubscribe","params":["0xb544f3328760ac404b9e3a4aec6f2ec0"],"id":2}
    
    // Confirmation that you’ve successfully unsubscribed
    {"jsonrpc":"2.0","id":2,"result":true}
    ```

## Need Help?

Contact us through [email](mailto:support@blockdaemon.com) or our [support page](/content/support/index.html) for any issues, bugs, or assistance you may need.
