# StreamMempoolTxs - Stream Pre-Consensus Transactions

Stream pre-consensus client blocks. A client block is a batch of signed transaction requests that a Hyperliquid node received from its peers before block inclusion. This method is V3-only.

Clone our [gRPC Code Examples Repository](https://github.com/dwellir-public/gRPC-code-examples) for complete, runnable V3 client setup in Go, Python, and Node.js.

A request in a mempool record is not guaranteed to land in a block. It can still fail, be replaced, be reordered, or never be included. Records carry requests only, with no responses. Use [StreamBlocks](https://www.dwellir.com/docs/hyperliquid/stream_blocks) for committed actions and their responses.

We guarantee mempool data availability only in our Tokyo region.

## When to Use This Method

`StreamMempoolTxs` is useful for:

- **Order-flow monitoring** - Observe signed actions before they are committed
- **Inclusion analysis** - Compare pre-consensus requests with committed blocks
- **Latency research** - Measure when requests reach the node relative to block time

## Method signature

```protobuf
rpc StreamMempoolTxs(StreamRequest) returns (stream Record) {}
```

The mempool feed is positioned by time only. Set `position.timestamp` (Unix milliseconds) or `position.timestamp_ns` (Unix nanoseconds); both are inclusive. A positioned call replays from that time and then tails live; an empty request tails newly received client blocks. `position.block_number` returns `INVALID_ARGUMENT`, and so does an explicit zero cursor.

The feed is not filterable. `ListFeeds` advertises no `filter_fields` for `mempool-txs`, so any `filter` constraint returns `INVALID_ARGUMENT`. The feed does not accept `StreamRequest.progress` either; setting it returns `INVALID_ARGUMENT`.

A record carries one whole client block and can exceed the default 4 MiB gRPC receive limit. Raise the client inbound message limit well above the default, for example `grpc.MaxCallRecvMsgSize(64 << 20)` in Go.

## Request Parameters

- `position.timestamp` (`int64, optional`): Inclusive Unix-millisecond receive-time cursor. Several records can share one millisecond. Omit the position to tail newly received client blocks.
- `position.timestamp_ns` (`int64, optional`): Inclusive Unix-nanosecond receive-time cursor; the exact resume cursor for this feed. Explicit zero is invalid.

## Request Example

```bash
grpcurl \
  -import-path content/docs/hyperliquid/grpc \
  -proto v3.proto \
  -max-msg-sz 67108864 \
  -H "x-api-key: ${DWELLIR_API_KEY}" \
  -d '{"position":{"timestamp_ns":"1790611197799360275"}}' \
  "${HYPERLIQUID_GRPC_ENDPOINT}" \
  hyperliquid_l1_gateway.v3.HyperliquidL1Gateway/StreamMempoolTxs
```

## Response Fields

- `block_number` (`optional int64, optional`): Always unset. Mempool records are pre-consensus and belong to no block.
- `timestamp` (`optional int64, optional`): Time the node received the client block, in Unix milliseconds.
- `data` (`bytes, required`): The source line as bytes: a JSON array of the receive time and the client block, with its tx_hash and signed_actions.
- `timestamp_ns` (`optional int64, optional`): The receive time in Unix nanoseconds. Resume from it with position.timestamp_ns.

## Successful Response

```protobuf
timestamp: 1790611197799
data: "[\"2026-09-28T15:59:57.799360275\",{\"tx_hash\":\"0x70f7f7919fbb85174223f6c5b957964813a9673f2ccb1d2f85d5a91e8a939c17\",\"signed_actions\":[{\"signature\":{\"r\":\"0x92c15a2df3a6cbe1464903a31abbdcca1ec54edcb6aee1ee0f8805beda05f289\",\"s\":\"0x792fc9397bd81cb8b80f481d8649c4cc1ae683b3113c586e9e8ac98d1fe58280\",\"v\":28},\"action\":{\"type\":\"noop\"},\"nonce\":1790611116331,\"expiresAfter\":1790611227625}]}]"
timestamp_ns: 1790611197799360275
```

## Error Responses

### Invalid argument

- Code: `INVALID_ARGUMENT`
- Description: A cursor is zero or malformed, the request sets position.block_number, a nonempty filter, or progress, or a timestamp is more than 2 seconds in the future.

### Not found

- Code: `NOT_FOUND`
- Description: The cursor is before the earliest retained record, or the selected endpoint does not serve the mempool feed.

### Records lost

- Code: `DATA_LOSS`
- Description: The stream fell behind the live feed. Reconnect from the last timestamp_ns to re-read the gap.

### Stream unavailable

- Code: `UNAVAILABLE`
- Description: No new records arrived before the stream timeout, or the stream failed mid-stream. Reconnect from the last timestamp_ns.

### Slow consumer

- Code: `DEADLINE_EXCEEDED`
- Description: The stream could not deliver records in time because the client read too slowly or stopped reading; reconnect from the last timestamp_ns.

### Replay capacity exhausted

- Code: `RESOURCE_EXHAUSTED`
- Description: Returned by the server: replay capacity for a positioned stream is temporarily unavailable; retry with backoff.

### Message too large

- Code: `RESOURCE_EXHAUSTED`
- Description: Returned by the client library: a record exceeded its receive limit. Retrying does not help; raise the client inbound message limit and reconnect from the last timestamp_ns.

### Unauthenticated

- Code: `UNAUTHENTICATED`
- Description: The request did not include usable authentication metadata.

### Permission denied

- Code: `PERMISSION_DENIED`
- Description: The supplied credential is not permitted to call this service.

## Response Stream

Each `Record` carries one client block:

- `block_number` is always unset. Mempool records are pre-consensus and have no block.
- `timestamp` is the time the node received the client block, in Unix milliseconds.
- `timestamp_ns` is the same receive time at nanosecond precision. Only the mempool feed sets it.
- `data` is the source line as bytes. The line is a JSON array, not an object.

## Record Format

Decoded `Record.data` is a two-element array: the receive time, then the client block. Hashes and signatures are truncated below:

```json
["2026-09-28T16:00:01.005217781", {"tx_hash": "0xeb4f...", "signed_actions": [
  {"signature": {"r": "0x1dc1...", "s": "0x161d...", "v": 27},
   "vaultAddress": "0x31ca...",
   "action": {"type": "order", "orders": [{"a": 190, "b": true, "p": "0.040938", "s": "15819", "r": false, "t": {"limit": {"tif": "Alo"}}}], "grouping": "na"},
   "nonce": 1790614526470}
]}]
```

| Field                           | Description                                                                                                                                                                                                       |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `[0]`                           | Receive time in UTC as an ISO-8601 string with nanosecond precision and no `Z` suffix                                                                                                                             |
| `[1].tx_hash`                   | Hash of the client block                                                                                                                                                                                          |
| `[1].signed_actions`            | Signed transaction requests in the client block                                                                                                                                                                   |
| `signed_actions[].action`       | The signed action in the exchange API's action encoding; order actions use the compact `a`/`b`/`p`/`s`/`r`/`t`/`c` keys. See the [action types reference](https://www.dwellir.com/docs/hyperliquid/stream_blocks#action-types-reference) |
| `signed_actions[].signature`    | `r`, `s`, `v` signature components                                                                                                                                                                                |
| `signed_actions[].nonce`        | Action nonce                                                                                                                                                                                                      |
| `signed_actions[].vaultAddress` | Present when the action acts for a vault or subaccount                                                                                                                                                            |
| `signed_actions[].expiresAfter` | Expiry time in Unix milliseconds, when the signer set one                                                                                                                                                         |

Records do not include the signer's address, only the signature (and `vaultAddress` where present), so the feed has no `users` filter.

## Ordering and Delivery

- One `Record` per client block, in the order the node received them. Receive times strictly increased across a 50,000-record sample, but treat that as observed behavior, not a guarantee.
- Several client blocks often share one millisecond. Resuming with `position.timestamp` redelivers every record of that millisecond; deduplicate on `tx_hash` if that matters.
- `timestamp_ns` is the exact cursor. Resuming with `position.timestamp_ns` set to the last received value redelivers exactly that one record, then continues.
- A cursor before the earliest retained record returns `NOT_FOUND`. `timestamp` is compared at millisecond precision, `timestamp_ns` exactly.
- A stream timestamp up to 2 seconds ahead of the server's clock starts a live tail; more than 2 seconds ahead returns `INVALID_ARGUMENT`.

## Error Handling and Reconnection

Persist the last `Record.timestamp_ns` that was set and reconnect with `StreamRequest.position.timestamp_ns` set to it. Replay is inclusive, so skip the one record that matches the saved cursor. A replay can skip a stored record whose timestamp does not parse, without an error.

The feed is high volume: every subscriber receives every client block, several megabytes per second uncompressed. Drain the stream continuously and enable gzip if bandwidth matters.

- **`DATA_LOSS`** - The stream fell behind the live feed and ended before sending any record after the loss. Reconnect from the last `timestamp_ns`; the replay re-reads the gap. A positioned stream that catches up with live data ends the same way if it then falls behind.
- **`UNAVAILABLE`** - No client blocks arrived before the stream timeout, for example while upstream peers are quiet, or the stream failed mid-stream. Reconnect from the last `timestamp_ns`.
- **`DEADLINE_EXCEEDED`** - The stream could not deliver records in time because the client read too slowly or stopped reading. Reconnect from the last `timestamp_ns`.
- **`RESOURCE_EXHAUSTED`** - From the client library, a record exceeded the client [receive limit](#method-signature); raise it before reconnecting, since retrying alone fails again. From the server, replay capacity is temporarily unavailable; retry with backoff.
- **`NOT_FOUND`** - The cursor is outside retained history, or the selected endpoint does not serve the mempool feed. Check `ListFeeds` for `mempool-txs`.

Once replay has caught up with live data, a growing gap between `Record.timestamp` and your clock means the client is not keeping up. Process records faster, or the stream ends with `DATA_LOSS`.

## Current Limitations

- **Pre-consensus only**: Records carry requests without responses, and inclusion is not guaranteed
- **No filtering**: Every subscriber receives every client block
- **Time positioning only**: `position.block_number` is rejected; resume on `timestamp_ns`
- **Replay History**: Available replay history varies by endpoint. A cursor outside retained history returns `NOT_FOUND`

## Resources

- **[GetMempoolTxs](https://www.dwellir.com/docs/hyperliquid/get_mempool_txs)** - Point-in-time mempool record retrieval
- **[StreamBlocks](https://www.dwellir.com/docs/hyperliquid/stream_blocks)** - Committed blocks with signed actions and responses
- **[ListFeeds](https://www.dwellir.com/docs/hyperliquid/list_feeds)** - Feed inventory and accepted cursor kinds

*Need help? Contact our [support team](mailto:support@dwellir.com) or check the [Hyperliquid gRPC documentation](https://www.dwellir.com/docs/hyperliquid/grpc).*
