Parameters
- subscription namestring
The type of event you want to subscribe to via WebSocket (e.g., newHeads, logs). This method supports the following subscription types:
- newHeads
Backward-compatible with Geth. Emits a notification when a new block header is finalized. Unlike Ethereum, Monad does not experience chain reorganizations — all emitted headers are final.
- logs
Backward-compatible with Geth. Emits logs included in finalized blocks that match the specified filter criteria. As with newHeads, Monad does not reorg.
- monadNewHeads
Emits the same block header data as newHeads, but includes additional Monad-specific metadata like block_id and commit_state. Recommended if backward compatibility is not required.
- monadLogs
Emits the same log data as logs, but with Monad-specific fields such as block_id and commit_state. Useful for observing execution of proposed blocks prior to finalization.
- monadEventStream
Streams sub-transaction-level EVM execution events directly as JSON objects. Includes detailed insights like call frames, account access, and storage changes. Primarily intended for observability and debugging — see realtime data docs for usage.
- dataobject
The arguments such as an address, multiple addresses, and topics. Note, only logs that are created from these addresses or match the specified topics will return logs
Returns
- resultstring
The hex encoded subscription ID. This ID will be attached to all received events and can also be used to cancel the subscription using eth_unsubscribe
1{2"id": 1,3"jsonrpc": "2.0",4"result": "0x1887ec8b9589ccad00000000000532da"5}
1{2"id": 1,3"jsonrpc": "2.0",4"result": "0x1887ec8b9589ccad00000000000532da"5}