---
title: "eth_subscribe"
description: "Subscribes to EVM events over WebSocket (Gnosis)"
url: "https://blockreq.com/docs/build/api-reference/gnosis/eth_subscribe/"
---

# eth_subscribe

**Network:** Gnosis · Mainnet · Chain ID `100` (`0x64`)

**Counts as 1 request.** See [Request Counting](https://blockreq.com/docs/pricing/request-counting/index.md).

`eth_subscribe` is available over WSS endpoints only. It creates a live subscription for event streams such as new heads or logs when the chain route has WSS enabled.

## Parameters

1. `String` - Subscription type, such as `newHeads`, `logs`, or `newPendingTransactions`.
2. `Object` - Optional filter object for subscription types such as `logs`.

## Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_subscribe",
  "params": ["newHeads"],
  "id": 1
}
```

## Code Examples

**TypeScript**

```typescript
const ws = new WebSocket("wss://gnosis-rpc.blockreq.com/v1/rpc/public");

ws.onopen = () => {
  ws.send(JSON.stringify({
  "jsonrpc": "2.0",
  "method": "eth_subscribe",
  "params": [
    "newHeads"
  ],
  "id": 1
}));
};
ws.onmessage = (event) => {
  console.log(JSON.parse(event.data));
};
```

**Python**

```python
import asyncio
import json

import websockets

async def main():
    async with websockets.connect("wss://gnosis-rpc.blockreq.com/v1/rpc/public") as ws:
        await ws.send('{"jsonrpc":"2.0","method":"eth_subscribe","params":["newHeads"],"id":1}')
        async for message in ws:
            print(json.loads(message))

asyncio.run(main())
```
