How to Access Ethereum RPC WebSocket

Learn how to connect with Ethereum WebSocket.

Supported WebSocket Methods

The Blockdaemon RPC API supports the following methods:

How To Access

Step 1: Authorize your request. Learn more: Authentication Guide

--headers 'Authorization: Bearer YOUR_API_KEY' 

Step 2: Use the following WebSocket URL:

wss://svc.blockdaemon.com/:protocol/:network/native?service_name=:service

Step 3: Specify an Ethereum method in the request body:

  • jsonrpc: Always "2.0".
  • id (int64): request ID.
  • method: Ethereum RPC WebSocket method. Such as eth_subscribe.
  • params:
    ├── Event types: The type of event to listen to (refer to Event types)
    └── Optional params: Optional parameters to describe the type of event to listen to (e.g., address)

For example, this request creates a new subscription for desired events.

--headers 'Authorization: Bearer YOUR_API_KEY' \
wss://svc.blockdaemon.com/ethereum/mainnet/native?service_name=ws \
'{"jsonrpc":"2.0","id": 2, "method": "eth_subscribe", "params": ["newPendingTransactions"]}'

Step 4: It will return a response containing the subscription ID (subscription). It is included in all notifications and is required when unsubscribing.

  • jsonrpc: Always "2.0"
  • method: Indicates that this response is related to an Ethereum subscription.
  • params:
    ├── result: Object contains details about the transaction, including its hash.
  • subscription The subscription ID associated with this response.
{
    "jsonrpc":"2.0",
    "method":"eth_subscription",
    "params":{
        "subscription":"0xc3b33aa549fb9a60e95d21862596617c",
        "result":"0xd6fdc5cc41a9959e922f30cb772a9aef46f4daea279307bc5f7024edc4ccd7fa"
    }
}

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.