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 MethodsEvent Types
eth_subscribe- newHeads
- logs
- newPendingTransactions
eth_unsubscribe
  • - 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
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 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
  • - 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

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
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:
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.