Skip to content

Instantly share code, notes, and snippets.

@yyolk
Last active July 7, 2021 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yyolk/d45625ef372890e44d7576d91ccf4966 to your computer and use it in GitHub Desktop.
Save yyolk/d45625ef372890e44d7576d91ccf4966 to your computer and use it in GitHub Desktop.
watch subscribed events to your xrpl node from the command line
#!/bin/bash
# install websocat
# cargo install --features=ssl websocat
# --features=ssl needs to be included to connect to wss://
# we use `<<<` to send a string into the command:
# echo '{"command"...}' | websocatt ...
# is equivalent
# use websocat to call the admin port
websocat ws://localhost:6006 -n \
<<< '{"command":"subscribe","streams":["ledger"]}' \
| jq '{txn_count,ledger_index,ledger_hash}'
# use websocat to call the default public port, if enabled, with self-signed cert (default with installation)
websocat -k wss://localhost:6006 -n \
<<< '{"command":"subscribe","streams":["ledger"]}' \
| jq '{txn_count,ledger_index,ledger_hash}'
# when you have the cert in the machine, such as the CA that signed xrplcluster.com, drop `-k`
websocat wss://xrplcluster.com -n \
<<< '{"command":"subscribe","streams":["ledger"]}' \
| jq '{txn_count,ledger_index,ledger_hash}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment