solana/docs/src/api/websocket/_slotsUpdatesSubscribe.mdx

93 lines
1.8 KiB
Plaintext

import {
DocBlock,
DocSideBySide,
CodeParams,
Parameter,
Field,
Values,
CodeSnippets,
} from "../../../components/CodeDocBlock";
<DocBlock>
## slotsUpdatesSubscribe
Subscribe to receive a notification from the validator on a variety of updates
on every slot
:::caution
This subscription is unstable
**NOTE: the format of this subscription may change in the future and it may not always be supported**
:::
<DocSideBySide>
<CodeParams>
### Parameters:
**None**
### Result:
`<integer>` - Subscription id (needed to unsubscribe)
</CodeParams>
<CodeSnippets>
### Code sample:
```json
{ "jsonrpc": "2.0", "id": 1, "method": "slotsUpdatesSubscribe" }
```
### Response:
```json
{ "jsonrpc": "2.0", "result": 0, "id": 1 }
```
</CodeSnippets>
</DocSideBySide>
#### Notification Format:
The notification will be an object with the following fields:
- `err: <string|undefined>` - The error message. Only present if the update is of type "dead".
- `parent: <u64|undefined>` - The parent slot. Only present if the update is of type "createdBank".
- `slot: <u64>` - The newly updated slot
- `stats: <object|undefined>` - The error message. Only present if the update is of type "frozen". An object with the following fields:
- `maxTransactionsPerEntry: <u64>`,
- `numFailedTransactions: <u64>`,
- `numSuccessfulTransactions: <u64>`,
- `numTransactionEntries: <u64>`,
- `timestamp: <i64>` - The Unix timestamp of the update
- `type: <string>` - The update type, one of:
- "firstShredReceived"
- "completed"
- "createdBank"
- "frozen"
- "dead"
- "optimisticConfirmation"
- "root"
```bash
{
"jsonrpc": "2.0",
"method": "slotsUpdatesNotification",
"params": {
"result": {
"parent": 75,
"slot": 76,
"timestamp": 1625081266243,
"type": "optimisticConfirmation"
},
"subscription": 0
}
}
```
</DocBlock>