eth_subscribe
Introduction
This API creates a new subscription for particular events. The node returns a subscription ID. For each event that matches the subscription, a notification with relevant data is sent together with the subscription ID. It consumes 10 CUs.
Parameter Description
Parameter |
Type |
Description |
---|---|---|
Event type |
String |
The type of event to listen to. |
Optional parameters |
String |
Optional parameters to include to describe the type of event to listen to (e.g. newHeads, newPendingTransactions, logs). |
Return Value
While the subscription is active, you will receive events formatted as an object described below:
- jsonrpc: always 2.0.
- method: always eth_subscription.
- params: an object with the following fields:
- subscription: the subscription ID returned by the API that creates this subscription. This ID will be attached to all received events and can also be used to cancel the subscription using eth_unsubscribe.
- result: an object whose contents vary depending on the event type.
Request
wscat -c wss://your-http-endpoint/v1/<API-KEY> -x '{"jsonrpc":"2.0", "id": 1, "method": "eth_subscribe", "params": ["logs"]}'
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot