Subscribing to events via Websocket
CometBFT emits different events, which you can subscribe to via Websocket. This can be useful for third-party applications (for analysis) or for inspecting state. List of events To connect to a node via websocket from the CLI, you can use a tool such as wscat and run:wss instead of ws.
You can subscribe to any of the events above by calling the subscribe RPC
method via Websocket along with a valid query.
Query parameter and event type restrictions
While CometBFT imposes no restrictions on the application with regards to the type of the event output, there are several considerations that need to be taken into account when querying events with numeric values.- Queries convert all numeric event values to
big.Float, provided bymath/big. Integers are converted into a float with a precision equal to the number of bits needed to represent this integer. This is done to avoid precision loss for big integers when they are converted with the default precision (64). - When comparing two values, if either one of them is a float, the other one will be represented as a big float. Integers are again parsed as big floats with a precision equal to the number of bits required to represent them.
- As with all floating point comparisons, comparing floats with decimal values can lead to imprecise results.
- Queries cannot include negative numbers
v0.38.x, floats were not supported as query parameters.