Im trying to send 0 ether to the same account with Web3j, however when i run this code it give me directly the transaction hash, even if the transaction has not been mined yet and still pending. I can't use the method Transfer.sendFund(..) because i need the nonce to be given by me.

RawTransaction rawTransaction = RawTransaction.createEtherTransaction(nonce, 
    gasPriceInWei, gasLimit, credentials.getAddress(), BigInteger.ZERO);

byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, 

String hexValue = Numeric.toHexString(signedMessage);

EthSendTransaction ethSendTransaction =

String transactionHash = ethSendTransaction.getTransactionHash();

System.out.println("transaction hash: " , transactionHash )

Does anyone have an idea to solve this probelm?

("web3j.ethSendRawTransaction(hexValue).send()" dont solve this)

(watch all new transactions in each new blocks until my transaction occure is a solution, but is there a better way)?


That worked for me:

while (true) {
    EthGetTransactionReceipt transactionReceipt = web3j
     if (transactionReceipt.getResult() != null) {

Your Answer

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

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