Fetch the last transaction occurred to a specific address


Author
Message
yehia67
y
Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)Attaching to Tangle (57 reputation)
Group: Forum Members
Posts: 4, Visits: 17
Hello everyone, I have a question on how to fetch the last transaction that occurred to a given address and I don't have the bundle.
I tried this javascript code
findTransactionObjects({ addresses: [userAddress] }).then(response => {//somecode})

I supposed that the last element of response array will be the last transaction but its not. I need to fetch data from the last transaction occurred could anyone help me with that? Thanks in advance.
HELP
Satish Joshi
S
Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)Attaching to Tangle (26 reputation)
Group: Forum Members
Posts: 2, Visits: 0
yehia67 - 29 Nov 2019
Hello everyone, I have a question on how to fetch the last transaction that occurred to a given address and I don't have the bundle.
I tried this javascript code
findTransactionObjects({ addresses: [userAddress] }).then(response => {//somecode})

I supposed that the last element of response array will be the last transaction but its not. I need to fetch data from the last transaction occurred could anyone help me with that? Thanks in advance.

Hi @yehia67, Directly there's no way you can fetch the last transaction associated with address but you can achieve this by doing some little modification on the mentioned API by like this :

iota.findTransactionObjects({ addresses: [userAddress] })
   .then(transactions => {
    //Sorting Array on Timestamp
    transactions.sort(function (x, y) {
      return y.timestamp - x.timestamp;
    });


After applying this sorting you can have the last transaction as the first element on the returned array I guess.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Login

Explore
Messages
Mentions
Search