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.
Best Answer
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:
gas * gas price
, i.e. minimum gas required for transation is 21000.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
For more details you can refer to the documentation of web3j.