Diese Frage ähnelt dieser . Ich versuche, alle Transaktionen in einer privaten Blockkette zu durchlaufen und nach bestimmten Daten zu suchen, die in den „Daten“-Feldern jeder Transaktion gesendet werden. Gilt folgender Ansatz:
// 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]]);
}
}
}
Ist dies eine korrekte Methode zum Durchlaufen von Transaktionen basierend auf einem Empfängeradressfilter?
Hier ist ein Skript, um Transaktionen zu/von einem Konto zu finden . Sie können einfach die Daten extrahieren, dh input
Felder aus allen Transaktionen.
Verwandt: