0

This question is similar to this one. I'm trying to iterate through all transactions in a private block chain and look for specific data sent in the 'data' fields of each transactions. Is the following approach valid:

    // Fetch all transaction logs with the specified address
    filter = web3.eth.filter({fromBlock: 0, toBlock: 'latest', address: to_addr});
    // Get all entries
    results = filter.get((function(error, result){
          if (!error)
            console.log("[I] Fetched all transactions sent or sent to " + to_addr);
           else
            console.log("[E] An error has occurred " + error);
    });

    var json_tuple;
    // Iterate through the transactions in the logs 
    for(var log in results) {
        var log_tx_hash = log.transactionHash;
        // Lookup transaction with hash
        var tx = web3.eth.getTransaction(log_tx_hash);
        // Check the to and from addresses. We skip transactions unrelated to the current sender
        if(tx.from === from_addr) {
            // Parse transaction data and check recipient
            json_tuple = JSON.parse(tx.input);
            if(field in json_tuple) {
                //Do something with a field of the input data sent
                // as a JSON object
                console.log("We have found a transaction with data: " + json_tuple[[field]]);

            }
         }
    }

Is this a correct way of iterating through transactions based on a recipient address filter?

1

Here is a Script to Find Transactions To/From an Account. You can just extract the data i.e., input fields from all the transactions.

Related:

Listing transactions in a private blockchain

Private chain: Extracting the “data” from an account?

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