> For the complete documentation index, see [llms.txt](/llms.txt).

# Subscribe to events

Use [WebSockets](/services/concepts/websockets/) to subscribe to events on the blockchain. For example, monitor an NFT smart contract to alert you when a new NFT is minted.

Stateless HTTP WebSockets are supported, however, we recommend using the WSS protocol to set up bidirectional stateful subscriptions.

info

For users on [Infura's credit pricing plan](/services/get-started/pricing/), subscribing and unsubscribing to events using the `eth_subscribe` and `eth_unsubscribe` methods consume credits from your daily quota. Credits are consumed for these actions to prevent spamming, even if no valuable data is sent.

View the [WebSocket pricing information](/services/concepts/websockets/#pricing) for a breakdown of the costs.

You need to be aware of the following when sending HTTP RPC requests:

- Silent failures - [Users need to manage client-side silent failures](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets%5FAPI/Writing%5FWebSocket%5Fservers#pings%5Fand%5Fpongs%5Fthe%5Fheartbeat%5Fof%5Fwebsockets).
- Load balancing - Unlike HTTP requests, WSS requests are not load-balanced to the fastest possible server.
- Retries - Retrying failed WebSocket requests typically requires custom JSON-RPC ID-based tracking, whereas support for retrying failed HTTP requests often is automatic, or easy to configure.
- Status codes - WebSockets use its own set of [status codes](https://pkg.go.dev/github.com/gorilla/websocket#pkg-constants)to provide users with a disconnection reason. The service will respond with the standard [EVM response codes](/services/reference/ethereum/json-rpc-methods/) for each JSON-RPC request.

## Example event subscription[​](#example-event-subscription "Direct link to Example event subscription")

The following WebSocket subscription example fires a notification each time a new header is appended to the chain:

```
$ wscat -c wss://mainnet.infura.io/ws/v3/<YOUR-API-KEY>
> {"jsonrpc":  "2.0",  "id":  1,  "method":  "eth_subscribe",  "params":  ["newHeads"]}

```
