2

I am sending a transaction through this code

public String transferEthByPk(String amount, String toAddress, String privateKey, Web3j web3j) { BigDecimal value = new BigDecimal(amount); Credentials credentials = EthWalletUtil.createCredentialByPrivateKey(privateKey); System.out.println("credentials"+credentials); if (credentials != null) { try { TransactionReceipt transactionReceipt= Transfer.sendFunds( web3j, credentials, toAddress, value, Convert.Unit.ETHER) .send(); String tx_Hash = transactionReceipt.getTransactionHash(); return tx_Hash; } catch (Exception e) { e.printStackTrace(); } } 

And I return this exception.

org.web3j.protocol.exceptions.TransactionException: Transaction receipt was not generated after 600 seconds for transaction: 0x28f2896b750e8480f87f831abd8fbdb00177527c31f5f9b4315ed8c8f374e481 

This exception occurs here

 TransactionReceipt transactionReceipt= Transfer.sendFunds( web3j, credentials, toAddress, value, Convert.Unit.ETHER) .send(); 

I can find this transactionHash in etherscan ,but it is always pending.I don't know why it is.

1 Answer 1

1

The transaction receipt was not generated after X seconds because the transfer is still in a pending state. The transaction receipt can only be gotten after a transaction has been mined.

It was caused probably due to a low gas price. Try increasing the gas price in subsequent transactions to avoid such delays.

2
  • 1
    It is always pending; I try to give a higher gas price ,it can't solve this; Commented May 25, 2019 at 8:08
  • 1
    Can you paste the TX hash here? Commented May 25, 2019 at 14:45

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.