Go-Ethereum – How to Transfer Ethereum From One Account to Another Using Address and Password

ethergo-ethereum

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:

  • 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.

Related Topic