> For the complete documentation index, see [llms.txt](https://docs.triton.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.triton.one/solana/rpc-methods/real-time-streaming/whirligig-websocket/logssubscribe.md).

# logsSubscribe

Subscribe to transaction logs over WebSocket, filtered by all, allWithVotes, or mentions of one address, with optional commitment.

## Request

{% tabs %}
{% tab title="wscat" %}

```bash
# npm install -g wscat
wscat -c "wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>" -w -1 \
  -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "logsSubscribe",
  "params": [
    {
      "mentions": ["11111111111111111111111111111111"]
    },
    {
      "commitment": "finalized"
    }
  ]
}'
```

{% endtab %}

{% tab title="Kit" %}

```typescript
import { address, createSolanaRpcSubscriptions } from "@solana/kit";

const rpc = createSolanaRpcSubscriptions("wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>");

const subscription = await rpc
  .logsNotifications(
    { mentions: [address("11111111111111111111111111111111")] },
    { commitment: "confirmed" }
  )
  .subscribe({ abortSignal: AbortSignal.timeout(50_000) });

for await (const notification of subscription) {
  console.log(notification);
}
```

{% endtab %}

{% tab title="web3.js" %}

```typescript
import { Connection, PublicKey } from "@solana/web3.js";

const connection = new Connection("https://<your-endpoint>.mainnet.rpcpool.com/<your-token>", {
  commitment: "confirmed",
  wsEndpoint: "wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>",
});

const subscriptionId = connection.onLogs(
  new PublicKey("11111111111111111111111111111111"),
  (logs, context) => {
    console.log("Logs:", logs);
    console.log("Context:", context);
  },
  "finalized"
);
```

{% endtab %}

{% tab title="Rust" %}

```rust
// Cargo.toml: anyhow = "1", futures = "0.3", solana-client = "~4.4",
// solana-commitment-config = "3", tokio = { version = "1", features = ["full"] }.
// Requires Rust 1.98.1 or newer (solana-client 4.4).
use anyhow::Result;
use futures::StreamExt;
use solana_client::{
    nonblocking::pubsub_client::PubsubClient,
    rpc_config::{RpcTransactionLogsConfig, RpcTransactionLogsFilter},
};
use solana_commitment_config::CommitmentConfig;

#[tokio::main]
async fn main() -> Result<()> {
    let pubsub_client = PubsubClient::new("wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>").await?;

    let filter = RpcTransactionLogsFilter::Mentions(vec![
        "11111111111111111111111111111111".to_string(),
    ]);

    let config = RpcTransactionLogsConfig {
        commitment: Some(CommitmentConfig::finalized()),
    };

    let (mut notifications, unsubscribe) = pubsub_client
        .logs_subscribe(filter, config)
        .await?;

    while let Some(notification) = notifications.next().await {
        println!("{:?}", notification);
    }

    unsubscribe().await;

    Ok(())
}
```

{% endtab %}
{% endtabs %}

In Rust, [`PubsubClient::logs_subscribe`](https://docs.rs/solana-pubsub-client/latest/solana_pubsub_client/nonblocking/pubsub_client/struct.PubsubClient.html#method.logs_subscribe) in the `solana-pubsub-client` crate sends this request.

## Parameters

**`filter`** · string | object · required

Filter describing which transactions should emit log notifications.

* `all` subscribes to all transactions except simple vote transactions
* `allWithVotes` subscribes to all transactions, including simple vote transactions. Alpenglow blocks contain no vote transactions.
* `{ "mentions": [<pubkey>] }` subscribes to transactions that mention a single base-58 encoded address

{% hint style="info" %}
The `mentions` filter currently supports exactly one address. Listing more than one returns an `Invalid params` error.
{% endhint %}

**`config`** · object

Optional configuration object.

**`commitment`** · string · default `finalized`

Values: `processed`, `confirmed`, `finalized` The commitment describes how finalized a block is at that point in time. See [Configuring State Commitment](https://solana.com/docs/rpc#configuring-state-commitment).

## Response

```json
{
  "jsonrpc": "2.0",
  "result": 24040,
  "id": 1
}
```

## Result

Subscription id. Pass this to [logsUnsubscribe](/solana/rpc-methods/real-time-streaming/whirligig-websocket/logsunsubscribe.md).

***

*Adapted from the* [*Solana `logsSubscribe` reference*](https://solana.com/docs/rpc/websocket/logssubscribe)*, maintained by the Solana Foundation.*

***

<i class="fa-life-ring">:life-ring:</i> Contact support by clicking the chat icon in your [customer dashboard](https://customers.triton.one)\ <i class="fa-briefcase">:briefcase:</i> Sales questions? [Contact us](https://triton.one/contact)\ <i class="fa-sparkles">:sparkles:</i> AI agent? Read [llms.txt](https://docs.triton.one/llms.txt)\ <i class="fa-rss">:rss:</i> Follow updates: [Blog](https://blog.triton.one) · [X](https://x.com/triton_one) · [YouTube](https://www.youtube.com/@triton_one_ltd) · [Telegram](https://t.me/tritonone) · [GitHub](https://github.com/rpcpool)
