I am creating transactions using web3j and passing some private data in that transaction. The transaction is also getting mined . I have subscribed to the mined blocks, where I am fetching the transactions added in the mined block. I want to retrieve the input data passed earlier, but unable to get it. Please help me here. Code for transacting using web3j:

RawTransactionManager rawTransactionManager =  new RawTransactionManager(web3j ,credentials,100,1000 * 15);
EthSendTransaction send = rawTransactionManager.sendTransaction(gasPrice, Transfer.GAS_LIMIT, toAddress, "<some private data>", BigInteger.valueOf(1));
String hash = send.getTransactionHash();

I also get the hash properly. Then, I subscribed to the blocks as follows:

Subscription subscriptionToBlocks = web3j.blockObservable(true).subscribe(block -> {
        List<TransactionResult> transactions = block.getBlock().getTransactions();
        if(transactions.size > 0){
            transactions.forEach(tx -> {
                  EthBlock.TransactionObject transaction = (EthBlock.TransactionObject) tx.get();
                  System.out.println("transaction data:"+transaction.getInput());

But this results in hex string, however, i want it decrypted again to process it further ie to fetch transfered value and receivers address. Let me know how can i get the original data that was sent ,i think there's inbuilt function in java to decode this input without providing any ABI ,but don't know what it is .

  • What are you using for private data? Quorum/Besu etc? Jan 31, 2020 at 10:32


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.