4

I need to listen for a new transactions on testnet submitted by wallet/address programmatically(js). I have tried iota.lib.js, but findTransactionObjects and getAccountData always returns null. Is there any other lib or other approach to listen or retrieve transactions?

1
  • 1
    Can you add the code snippets of what you tried?
    – Helmar
    Jul 3, 2018 at 15:31

1 Answer 1

4

Solution: seed must be recipient of transaction

function getLastTransaction(seed){
    iota.api.getAccountData(seed, (error, success) => {
        if(error){
            console.log(error)
        } else {
            let long = success.transfers.length
            let lastT = success.transfers[long-1][0]
            let tx = 
            {
                'hash':lastT.hash,
                'value':lastT.value,
                'confirmed':lastT.persistence, 
                'message' : lastT.signatureMessageFragment
            }
            var message = tx.message.replace(/\d+$/, "")

            console.log(iota.utils.fromTrytes(message));
        }
    })
}

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.