mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 22:23:11 +00:00
* Ignore generated/copied RPC docs Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync vuepress config with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs package-lock.json with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs redirects with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs versions with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update OpenAPI version to v0.34 Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync DOCS_README with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update all v0.34.x docs references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update v0.34 OpenAPI references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update repo doc links from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update code comment references from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update repo root doc links from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update repo root doc links for docs.tendermint.com from master to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Build v0.34.x as "latest" Signed-off-by: Thane Thomson <connect@thanethomson.com> * Explicitly mark v0.34 docs as latest in version selector Signed-off-by: Thane Thomson <connect@thanethomson.com> * Add nav link to main and clearly mark as unstable Signed-off-by: Thane Thomson <connect@thanethomson.com> * Direct all docs.tendermint.com links to v0.34 on v0.34.x Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update all relevant links on v0.34.x branch to be v0.34-specific Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update changelog refs to docs.tendermint.com Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update remaining GH master link to main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Sync docs build and nav config with main Signed-off-by: Thane Thomson <connect@thanethomson.com> * Migrate spec links to GitHub repo from docs site Signed-off-by: Thane Thomson <connect@thanethomson.com> Signed-off-by: Thane Thomson <connect@thanethomson.com>
76 lines
2.1 KiB
Markdown
76 lines
2.1 KiB
Markdown
---
|
|
order: 7
|
|
---
|
|
|
|
# Subscribing to events via Websocket
|
|
|
|
Tendermint emits different events, which you can subscribe to via
|
|
[Websocket](https://en.wikipedia.org/wiki/WebSocket). This can be useful
|
|
for third-party applications (for analysis) or for inspecting state.
|
|
|
|
[List of events](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants)
|
|
|
|
To connect to a node via websocket from the CLI, you can use a tool such as
|
|
[wscat](https://github.com/websockets/wscat) and run:
|
|
|
|
```sh
|
|
wscat ws://127.0.0.1:26657/websocket
|
|
```
|
|
|
|
You can subscribe to any of the events above by calling the `subscribe` RPC
|
|
method via Websocket along with a valid query.
|
|
|
|
```json
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"method": "subscribe",
|
|
"id": 0,
|
|
"params": {
|
|
"query": "tm.event='NewBlock'"
|
|
}
|
|
}
|
|
```
|
|
|
|
Check out [API docs](https://docs.tendermint.com/v0.34/rpc/) for
|
|
more information on query syntax and other options.
|
|
|
|
You can also use tags, given you had included them into DeliverTx
|
|
response, to query transaction results. See [Indexing
|
|
transactions](./indexing-transactions.md) for details.
|
|
|
|
## ValidatorSetUpdates
|
|
|
|
When validator set changes, ValidatorSetUpdates event is published. The
|
|
event carries a list of pubkey/power pairs. The list is the same
|
|
Tendermint receives from ABCI application (see [EndBlock
|
|
section](https://github.com/tendermint/tendermint/blob/v0.34.x/spec/abci/abci.md#endblock) in
|
|
the ABCI spec).
|
|
|
|
Response:
|
|
|
|
```json
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 0,
|
|
"result": {
|
|
"query": "tm.event='ValidatorSetUpdates'",
|
|
"data": {
|
|
"type": "tendermint/event/ValidatorSetUpdates",
|
|
"value": {
|
|
"validator_updates": [
|
|
{
|
|
"address": "09EAD022FD25DE3A02E64B0FE9610B1417183EE4",
|
|
"pub_key": {
|
|
"type": "tendermint/PubKeyEd25519",
|
|
"value": "ww0z4WaZ0Xg+YI10w43wTWbBmM3dpVza4mmSQYsd0ck="
|
|
},
|
|
"voting_power": "10",
|
|
"proposer_priority": "0"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|