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

Subscribing to Events

SDK and Tendermint Events

It is possible to subscribe to Events via Tendermint's Websocket. This is done by calling the subscribe RPC method via Websocket:

    "jsonrpc": "2.0",
    "method": "subscribe",
    "id": "0",
    "params": {
        "query": "tm.event='eventCategory' AND eventType.eventAttribute='attributeValue'"

The main eventCategory you can subscribe to are:

  • NewBlock: Contains events triggered during BeginBlock and EndBlock.

  • Tx: Contains events triggered during 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.

The type and attribute value of the query allow you to filter the specific event you are looking for. For example, a MsgEthereumTx transaction triggers an event of type ethermint and has sender and recipient as attributes. Subscribing to this event would be done like so:

    "jsonrpc": "2.0",
    "method": "subscribe",
    "id": "0",
    "params": {
        "query": "tm.event='Tx' AND ethereum.recipient='hexAddress'"

where hexAddress is an Ethereum hex address (eg: 0x1122334455667788990011223344556677889900).

Ethereum JSON-RPC Events

Uptick also supports the Ethereum JSON-RPC filters calls to subscribe to state logs, blocks or pending transactions changes.

Under the hood, it uses the Tendermint RPC client's event system to process subscriptions that are then formatted to Ethereum-compatible events.

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545


Then you can check if the state changes with the eth_getFilterChanges call:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x3503de5f0c766c68f78a03a3b05036a5"],"id":1}' -H "Content-Type: application/json" http://localhost:8545


Websocket Connection

Tendermint Websocket

To start a connection with the Tendermint websocket you need to define the address with the --rpc.laddr flag when starting the node (default tcp://

uptickd start --rpc.laddr="tcp://"

Then, start a websocket subscription with ws

# connect to tendermint websocket at port 8080 as defined above
ws ws://localhost:8080/websocket

# subscribe to new Tendermint block headers
> { "jsonrpc": "2.0", "method": "subscribe", "params": ["tm.event='NewBlockHeader'"], "id": 1 }

Ethereum Websocket

Since Uptick runs uses Tendermint Core as it's consensus Engine and it's built with the Cosmos SDK framework, it inherits the event format from them. However, in order to support the native Web3 compatibility for websockets of the Ethereum's PubSubAPI, Uptick needs to cast the Tendermint responses retrieved into the Ethereum types.

You can start a connection with the Ethereum websocket using the flag when starting the node (default ""):

uptickd start  --json-rpc.address"""" --evm.rpc.api="eth,web3,net,txpool,debug" --json-rpc.enable

Then, start a websocket subscription with ws

# connect to tendermint websocet at port 8546 as defined above
ws ws://localhost:8546/

# subscribe to new Ethereum-formatted block Headers
> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]}
< {"jsonrpc":"2.0","result":"0x44e010cb2c3161e9c02207ff172166ef","id":1}

Last updated