0

I want to transfer ether from one account to another using Web3j. I have account address and password.

How to submit transaction?

EDIT 1: I'm using this way to send the transaction:

HttpService httpService = new HttpService(envConfiguration.getTestnetkeyStorePath());
            Admin admin = Admin.build(httpService);

            PersonalUnlockAccount  credentials1 = admin.personalUnlockAccount(from, existingpassword).send();
            LOGGER.info("credentials  :"+credentials1.accountUnlocked());

            Transaction trx = Transaction.createEtherTransaction(from, nonce, gasprice, gaslimit, to, amount);
            EthSendTransaction ethSendTransaction = admin.personalSendTransaction(trx, existingpassword).send();
             transactionHash = ethSendTransaction.getTransactionHash();
            LOGGER.info("Transaction hash :"+transactionHash);

But I'm getting transaction hash as null, Don't know what is going wrong.? ANy help.? PS: Thanks in advance.

2
  • the answer to this question is on Google
    – Nulik
    Mar 27, 2018 at 17:05
  • @Nulik, I have tried but didn't find any suitable answer. If you have please share the link. Thanks. Mar 27, 2018 at 18:38

1 Answer 1

1

Account address and password alone cannot be used alone. The password you are talking about is used to decrypt the encrypted private key.

There is an article which you can use to send ether from one party to another.

The steps followed are as follows:

  • Create Web3j object to connect ethereum server.
  • Calculate transaction fee which is essential for doing transaction. Transaction fee will be equal to gas * gas price, i.e. minimum gas required for transation is 21000.
  • Create credentials object.
  • Prepare txn by adding the details.

    var rawTx = { nonce: web3.toHex(nonce), gasLimit: web3.toHex(41334), gasPrice: web3.toHex(10), to: addressTo, from: addressFrom, value: web3.toHex(100) }

  • Sign the txn using the private key

  • Serialize the txn and convert it to hex
  • Send the raw txn.

For more details you can refer to the documentation of web3j.

Your Answer

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

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