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?

Helmar
  • 1,293
  • 1
  • 15
  • 28
iobeta123
  • 89
  • 4

1 Answers1

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));
        }
    })
}
iobeta123
  • 89
  • 4