Этот вопрос похож на этот . Я пытаюсь выполнить итерацию по всем транзакциям в частной цепочке блоков и искать конкретные данные, отправленные в поля «данные» каждой транзакции. Допустим ли следующий подход:
// 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]]);
}
}
}
Является ли это правильным способом повторения транзакций на основе фильтра адреса получателя?
Вот скрипт для поиска транзакций на/с учетной записи . Вы можете просто извлечь данные, т. е input
. поля, из всех транзакций.
Связанный: