When building blockchain or fintech apps, reacting to real-time blockchain events is key.
Whether you're sending confirmation emails, triggering fiat payouts, or updating dashboards — knowing exactly when a transaction happens gives your app superpowers.
In this post, I’ll show you how to listen for Sui transactions in real time using JavaScript, and walk through a real-world use case: triggering a Naira payout after receiving SUI.
This is the same pattern I used while building suiFi
— a swap engine that converts SUI directly to Nigerian Naira. 🚀
🛠️ Prerequisites
- Node.js installed
- A basic understanding of the Sui blockchain
- Familiarity with JavaScript/TypeScript
- An RPC provider (e.g.
wss://rpc.testnet.sui.io
)
🔧 Step 1: Project Setup
mkdir sui-listener
cd sui-listener
npm init -y
npm install @mysten/sui.js
- Then create a file named index.js.
Step 2: Connect to Sui WebSocket
const { WebSocketClient } = require('@mysten/sui.js');
const client = new WebSocketClient('wss://rpc.testnet.sui.io');//replace RPC with mainnet
client.connect().then(() => {
console.log('✅ Connected to Sui WebSocket');
});
const walletAddress = '0xYOUR_WALLET_HERE';
client.subscribeTransactionEvents(
{
filter: {
InputObject: walletAddress,
},
},
(event) => {
console.log('🔔 New Sui Transaction Detected:');
console.log(JSON.stringify(event, null, 2));
// 🔁 Add your action logic here
}
);
npm install axios
const axios = require('axios');
async function sendPayout(ngnAmount, recipient) {
await axios.post('https://your-fintech-api.com/payout', {
amount: ngnAmount,
recipientAccount: recipient,
});
}
Final Thoughts
Listening to blockchain transactions is more than just reading data — it’s about empowering real-world action in real time.
If this helped you or you build something with it, tag me — I’d love to see what you’re working on!
Follow me for more DevRel content and practical guides on Web3, fintech, and developer experience.
💬 Twitter/X: [https//:x.com/Jeffreyonsui/]
📁 GitHub: [https://github.com/Jeffreyxdev/]
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.