# Swap Tracker

This short example shows how you can build a program that monitors the blockchain for events such as swaps. In order to run the example code provided, you will need access to the WebSockets endpoint of a Terra node. The public nodes do not expose this API, and you will need to configure your own node or get access from a separate provider.

from jigu import Terra
from jigu.core.msg import MsgSwap
from jigu.listener import start_listeners

soju = Terra("soju-0013", "https://soju-lcd.terra.dev",

@soju.tx_listener({"message.action": MsgSwap.action})
def process_swap(listener, tx_info):
    swap = tx_info.msgs.events.swap[0]
        f"{swap.trader[0]} swapped {swap.swap_coin[0]} for {swap.offer[0]}, "
        + f"paying {swap.swap_fee[0]} in fees!"


You should replace ws://node.terra:26657 with the address and port of your node.

Updated on: 3/2/2020, 12:38:51 PM