RPC WebSocket Support (BETA)

❗️

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 GroupChains
Ethereum-CompatibleEthereum, Polygon, Arbitrum, Optimism, Base, Cronos
SolanaSolana
PolkadotPolkadot, Kusama

WebSocket Methods & Compute Units

📘

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


Solana

Ethereum-Compatible Chains

Supported Methods Event Types

eth_subscribe

  • newHeads
    - logs
    - newPendingTransactions

eth_unsubscribe

CU Consumption

  • Subscribe / Unsubscribe request:
    1 CU per request

  • Confirmation responses:
    1 CU

  • Event messages (e.g., newHeads):
    10 CU per message

🚧

The minimum charge is 1 CU per action.

💡 Billing Example – Subscribe to eth_subscribe with newHeads

Click to expand
DescriptionCountCU per ActionTotal CU
🔼 Open WebSocket connection11 CU1
🔼 Send eth_subscribe request11 CU1
🔽 Receive confirmation from node11 CU1
🔽 Receive newHeads messages510 CU50
🔼 Send eth_unsubscribe request11 CU1
🔽 Receive unsubscribe confirmation11 CU1

Total Compute Units: 55 CU


Solana

Solana

Supported MethodsCU per SubscriptionSubscribes ToCU per Message
accountSubscribe1 CUaccountNotification5 CU
accountUnsubscribe1 CU
logsSubscribe1 CUlogsNotification5 CU
logsUnsubscribe1 CU
programSubscribe1 CUprogramNotification10 CU
programUnsubscribe1 CU
signatureSubscribe1 CUsignatureNotification5 CU
signatureUnsubscribe1 CU
slotSubscribe1 CUslotNotification5 CU
slotUnsubscribe1 CU
slotsUpdatesSubscribe1 CUslotsUpdatesNotification5 CU
slotsUpdatesUnsubscribe1 CU

CU Consumption (Solana)

  • 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

DescriptionCountCU per ActionTotal CU
🔼 Send accountSubscribe request11 CU1
🔽 Receive confirmation response11 CU1
🔽 Receive accountNotification messages85 CU40
🔼 Send accountUnsubscribe request11 CU1
🔽 Receive unsubscribe confirmation11 CU1

Total Compute Units: 44 CU


Solana

Polkadot

Supported MethodsCU per SubscriptionSubscribes ToCU per Message
beefy_subscribeJustifications1 CUbeefy_justifications1 CU
beefy_unsubscribeJustifications1 CU
chain_subscribeFinalizedHeads1 CUchain_finalizedHead1 CU
chain_unsubscribeFinalizedHeads1 CU
chain_subscribeAllHeads1 CUchain_allHead1 CU
chain_unsubscribeAllHeads1 CU
chain_subscribeNewHeads1 CUchain_newHead1 CU
chain_unsubscribeNewHeads1 CU
grandpa_subscribeJustifications1 CUgrandpa_justifications1 CU
grandpa_unsubscribeJustifications1 CU
state_subscribeRuntimeVersion1 CUstate_runtimeVersion1 CU
state_unsubscribeRuntimeVersion1 CU
state_subscribeStorage1 CUstate_storage5 CU
state_unsubscribeStorage1 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

DescriptionCountCU per ActionTotal CU
🔼 Send state_subscribeStorage request11 CU1
🔽 Receive confirmation response11 CU1
🔽 Receive state_storage notifications65 CU30
🔼 Send state_unsubscribeStorage request11 CU1
🔽 Receive unsubscribe confirmation11 CU1
Total Compute Units34 CU

How to Connect

To connect to the WebSocket endpoint, follow these steps:

  1. Authorize your request using one of the following methods:
curl --header "Authorization: Bearer YOUR_API_KEY"
curl --header "X-API-KEY: YOUR_API_KEY"
  1. You'll need to install a WebSocket client like wscat, or any other tool you prefer to connect.
npm install -g wscat   //One-time installation
  1. Connect to the WebSocket URL with the following URL pattern:
wss://svc.blockdaemon.com/:protocol/:network/native

For example, for Ethereum Mainnet:

wscat --header "Authorization: Bearer YOUR_API_KEY" \
-c wss://svc.blockdaemon.com/ethereum/mainnet/native
  1. Once connected, you can send and receive messages using JSON-RPC:
// 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 or our support page for any issues, bugs, or assistance you may need.