Im trying to fetch transaction logs from ganache using web3j library to send it as an api ,is there any way where i can get all transactions from ganache quickly?

public List<Transaction> test() throws InterruptedException, ExecutionException, IOException {
    String address = "0xeedc155ae507fb0a9becae6315286183a23229b0";
    List<Transaction> transactions = new ArrayList<Transaction>();
    Web3j web3j = web3jConfig.initializeWeb3j();
    System.out.println("test Running.......");
    BigInteger block = web3j.ethBlockNumber().send().getBlockNumber();
    System.out.println("blockno:" + block.intValue());
    int block_no = block.intValue();

Flowable<Transaction> replyBlocks   = web3j.replayPastTransactionsFlowable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST);
    System.out.println("into replyBlocks");
        transactions.add(temp); //It's an collection object,and value is not adding into it 
})  ;

    return transactions;

web3j.replayPastTransactionsFlowable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST); *this function is working fine when print data to console but don't know why its not adding its data into an List object which i want to send as an api

  • What is 0xeedc155ae507fb0a9becae6315286183a23229b0"? – Majd TL Feb 12 at 19:07
  • Its an contract address @MajdTL , i just copy pasted this code from github to what it does ! – Aniket Feb 13 at 5:24
  • So you want to extract all transactions logs (not transactions) that sent to a specific smart contract ? – Majd TL Feb 13 at 8:14
  • @MajdTL yes i need all transaction logs but not from a specific contract as erc20 already provided inbuilt flowable function to achieve contract based blocks informations,I'm actully looking for a way where i can fetch all transactionLogs of ether through web3j class,currenlt using test network and ganache – Aniket Feb 13 at 12:03
  • 1
    why replayPastTransactionsFlowable and not replayTransactionsFlowable? – Majd TL Feb 13 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.