Wallet deposit notification in plugins

I am developing a plugin and I need to know when one of my users receive a crypto deposit to his wallet.

I am going to use this feature for payments and it would be extremely important to know exactly when a deposit is made with the information about the deposit like amount, confirmation status etc.

2 Likes

You can use the following code to listen to deposit and withdrawals in the exchange real-time and use it in your plugin:

toolsLib.database.subscriber.subscribe('channel:events');

toolsLib.database.subscriber.on('message', async (channel, message) => {
	if (channel === 'channel:events') {
		const { type, data } = JSON.parse(message);
	}

	if (type === 'deposit') {
		// you have a deposit and you can parse the deposit data
	} else if (type === 'withdrawal') {
		// you have a withdrawal and you can parse the withdrawal data
	}
})
2 Likes

This feature is really nice. Is there a way to use this outside of the plugin using some APIs?

You can use the npm package HollaEx Node Lib and subscribe to admin topic like this:

client.connect(['admin']);

client.ws.on('message', (data) => {
   data = JSON.parse(data);
   console.log(data);
});

If you are using other programming language other than nodejs you can refer to the apidocs and use the admin topic in the websocket.

Note that this only works if you are using the admin keys obviously.

1 Like