2

is any of you able to subscribe to ZeroMQ with address as a topic? According to the documentation this should be possible by putting the public address as a topic in socket.subscribe(). I have no problem with any other topics such as 'tx', 'sn' and so on. But when I subscribe to the address, there are no messages coming even though there is activity on the specified address. I sent few of IOTAs there and not a single transaction came from the queue. Was anyone able to subscribe to the address successfully? Any idea what I could be doing wrong?

Thank you in advance, any help would be much appreciated.

2 Answers 2

3

Make sure you use the address (81digits) without the check-digits (90digits). I also fell into this pitfall.

1
  • Thank you. The address must be 81 digits. I didn't find the mistake !!!
    – Paloma Gil
    Commented Dec 10, 2019 at 11:17
1

I just tried it out and it worked for me.

Here's the code:

let zmq = require('zeromq')
let sock = zmq.socket('sub')

sock.connect('tcp://zmq.devnet.iota.org:5556')
//sock.subscribe('tx')
//sock.subscribe('sn')

//My address
sock.subscribe('HELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDD')


sock.on('message', msg => {
    const data = msg.toString().split(' ') // Split to get topic & data
    switch (
    data[0] // Use index 0 to match topic
    ) {
        case 'tx':
            console.log(`I'm a TX!`, data)
            break
        case 'sn':
            console.log(`I'm a confirmed TX`, data)
            break
        case 'HELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDHELLOWORLDD':
            console.log(`I'm activity concerning that specific address`, data)
            break
    }
})

Maybe you forgot to include the case '<address>': statement in the switch statement?

Also remember that in this example the zmq-endpoint tcp://zmq.devnet.iota.org:5556 is concerning the devnet tangle and not the one on the mainnet. So transactions concerning the address in my example would also have to happen on the devnet.

1
  • Thank you for your answer. In the end I didn't make it work. I have tried devnet and even the mainnet and nothing. I wasn't using the switch there and was just logging every message coming through and not a single one was received. In the end I just stick with listening to every transaction and filtering them by receiving address. Commented Mar 7, 2019 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.