# 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",
"ws://52.78.69.160:26657")
@soju.tx_listener({"message.action": MsgSwap.action})
def process_swap(listener, tx_info):
tx_info._pp
swap = tx_info.msgs.events.swap[0]
print(
f"{swap.trader[0]} swapped {swap.swap_coin[0]} for {swap.offer[0]}, "
+ f"paying {swap.swap_fee[0]} in fees!"
)
listener.stop_listening()
start_listeners(process_swap)
You should replace ws://node.terra:26657
with the address and port of your node.