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 Answer
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));
}
})
}