0

I am trying to get the recent IN transaction of the account while i try

web3.eth.getTransactionCount("0xF092966e7bcc2b5646e0F0c20A715584DB37cd4B").then(function(trans){
    console.log(trans);
});

This returns account transactions count.

I refer web3 documentation and refer net i found the script getTransactionsByAccount Common useful JavaScript snippets for geth

Is any another way to find IN transaction of the account using web3.js . Lastest last IN transaction is enough .

Sammu Sundar
  • 219
  • 5
  • 14

1 Answers1

1

I think it would be easier and faster to use Amberdata.io. If you get a free api key then you can do the following to get the latest IN transaction.

It would look something like this:

curl \
  -X GET \
  -H "x-api-key: UAK000000000000000000000000demo0001" \
"https://web3api.io/api/v1/addresses/0xF092966e7bcc2b5646e0F0c20A715584DB37cd4B/transactions?to=0xF092966e7bcc2b5646e0F0c20A715584DB37cd4B&size=1"

The transactions are returned ordered by timestep. The to filters by a to address. In this case we want all transactions where the to address is the address we are querying and we want the first one so I put size=1. Although if you remove that you'll get every IN transaction.

Hope that helps!

foba
  • 543
  • 2
  • 12