3

I am using web3.js and geth to do my coding. I have an Ether Account (Not a Wallet Contract) that will be receiving funds from clients. The clients will be writing a number in the DATA field (that you see when you click "SHOW MORE OPTIONS").

But now I need to be able to look at the history of transactions to my specific account, and view the Data being sent to it.

QUESTION:

Is there a function in web3 to view the most recent transactions being sent to an Account? If not for an account, does that exist for a Wallet Contract? I know that the following function exists:

var transactionObject = web3.eth.getTransaction(hash);

But I do not have the hash for a transaction that a client does to me.

4

If you are working with a Parity node you can utilise the trace_filter JSONRPC method of their 'trace' module (as detailled here).

This will allow you to return a JSON array of all transactions to your address. Simply process this returned JSON, and extract the data field from each.

web3 is simply a Javascript interface to interact with RPC endpoints. Whilst web3.js does not have the parity trace module in built, there are a number of libraries available for many programming languages that will allow you to do so.

You can simply make a CURL request to your node as outlined in the documentation.

curl --data '{"method":"trace_filter","params":[{"fromBlock":"0x2ed0c4","toBlock":"0x2ed128","toAddress":["0x8bbB73BCB5d553B5A556358d27625323Fd781D37"]}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

  • oh does that mean the code has to look through all the blocks that are being processed? and once it reaches one that goes to my accounts address, it saves the data? – Webeng Jul 17 '17 at 19:58
  • I am unsure how Parity works under the hood, but it must index the data in some capacity as it is extremely quick. – Thomas Clowes Jul 17 '17 at 21:06
  • Does this work for incoming internal transactions? – Thomas Jay Rush Jul 19 '17 at 3:19
  • The trace returns the internal transactions as an array. There is also the trace_transaction endpoint for tracing a specific transaction. – Thomas Clowes Jul 19 '17 at 15:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.