What I have
1. I have setup my own private blockchain.
2. mining started on my node

What I want
1. I want to know all transaction object which executed last one or 24 hour and their total ether value.

1 Answer 1


You can check all blocks downwards from the current while checking block timestamp. Here is a simple node.js script:

const Web3 = require('web3');
const web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

const date = new Date();
const minTimestamp = date.setHours(date.getHours() - 1) / 1000;
console.log('Retreiving all transactions from', date);

const {currentBlock, highestBlock} = web3.eth.syncing;
if(currentBlock < highestBlock) {
  console.log('Warning! Node is not synced:\n', web3.eth.syncing);

let blockNum = web3.eth.blockNumber;
const transactions = [];

while(true) {
  const block = web3.eth.getBlock(blockNum);
  if(block.timestamp < minTimestamp) break;
  transactions.push.apply(transactions, block.transactions);

console.log('Retreived', transactions.length, 'transactions');

const total = transactions.reduce(
  (sum, tx) => web3.eth.getTransaction(tx).value.plus(sum),
  new web3.BigNumber(0)

console.log('Total value is', web3.fromWei(total, 'ether').toNumber(), 'Ether');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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