Private Blockchain – Listing Transactions in a Private Blockchain

go-ethereumjavascriptprivate-blockchainquerytransactions

In a private blockchain, is it possible to list the transactions based on from and to parameters in a transaction.

Is it possible to check the latest transaction from or to an address?

Also, is it possible to check the time of a specific transaction?

Since all this data is in the blockchain, can we do this through the javacsript console in geth?

Best Answer

Take a look at web3.ETH.filter

Parameters

String|Object - The string "latest" or "pending" to watch for changes in the latest block or pending transactions respectively. Or a filter options object as follows:

  1. String|Object - The string "latest" or "pending" to watch for changes in the latest block or pending transactions respectively. Or a filter options object as follows:
    • fromBlock: Number|String - The number of the earliest block (latest may be given to mean the most recent and pending currently mining, block). By default latest.
    • toBlock: Number|String - The number of the latest block (latest may be given to mean the most recent and pending currently mining, block). By default latest.
    • address: String - An address or a list of addresses to only get logs from particular account(s).
    • topics: Array of Strings - An array of values which must each appear in the log entries. The order is important, if you want to leave topics out use null, e.g. [null, '0x00...']. You can also pass another array for each topic with options for that topic e.g. [null, ['option1', 'option2']]

EG:

// watch for changes 

var filter = web3.ETH.filter({address: "0xYOURADDRESS"});

filter.watch(function(error, result){
  if (!error)
    console.log(result);
});

Link for the script (not filter) to get the transactions to/from an account.

Issue in the Go-ethereum github to implement this functionality (eth.listTransactions) by default.

Latest update from Ethereum Developers:

Locking this issue but leaving it open.

We're considering a suitable implementation for this feature.

No ETA.

Related Topic