Events are objects that contain information about the execution of the application. They are mainly used by service providers like block explorers and wallet to track the execution of various messages and index transactions.
# Pre-requisite Readings
Events are implemented in the Cosmos SDK as an alias of the ABCI
Event type and
take the form of:
type, which is meant to categorize an event at a high-level (e.g. by module or action).
- A list of
attributes, which are key-value pairs that give more information about the categorized
Events are returned to the underlying consensus engine in the response of the following ABCI messages:
attributes, are defined on a per-module basis in the module's
/types/events.go file, and triggered from the module's
EventManager. In addition, each module documents its events under
In Cosmos SDK applications, events are managed by an abstraction called the
EventManager tracks a list of
Events for the entire execution flow of a
EventManager comes with a set of useful methods to manage events. Among them, the one that is
used the most by module and application developers is the
EmitEvent method, which tracks
event in the
Module developers should handle event emission via the
EventManager#EmitEvent in each message
Handler and in each
EndBlock handler. The
EventManager is accessed via
Context, where event emission generally follows this pattern:
handler function should also set a new
EventManager to the
context to isolate emitted events per
Handler concept doc for a more detailed
view on how to typically implement
Events and use the
EventManager in modules.
# Subscribing to Events
It is possible to subscribe to
Events via Tendermint's Websocket.
This is done by calling the
subscribe RPC method via Websocket:
eventCategory you can subscribe to are:
DeliverTx(i.e. transaction processing).
ValidatorSetUpdates: Contains validator set updates for the block.
These events are triggered from the
state package after a block is committed. You can get the
full list of
event categories here.
attribute value of the
query allow you to filter the specific
event you are looking for. For example, a
transfer transaction triggers an
event of type
Transfer and has
attributes (as defined in the
events file of the
bank module). Subscribing to this
event would be done like so:
senderAddress is an address following the
Learn about SDK telemetry