0

EDIT: I am using android platform

I think I'm a bit confused conceptually. I would appreciate it if someone could answer these few questions for me as I'm trying to make an app so that I can be clear on exactly what's going on here. I'm trying to read and decipher the documentation at the same time.

-I have generated my address and private key using web3j ECKeyPair class

Now I need to be able to send that ether to an address using that data and I'm not sure how I'm supposed to go about doing it

  • I think I'm supposed to use something called a rawtransaction but again my understanding is hazy

  • I would also like to be able to encrypt my private key however I saw that it encrypts the data into a keystore file. Is there any way to clear out the unneccesary data here as I'm only trying to encrypt the private key using a password.

If a more knowledgeable member than myself could clear up the steps involved in "signing a transaction" so that ether can be sent from one address to another, you'd be a huge help to my design project.

I also don't understand how transactions can be signed offline as I thought the point in signing a transaction was so it could be verified by the network

Thank you.

0

If i understand your question correctly, you should be able to just use web3.eth.sendTransaction by passing in a transaction object.

var transactionObject = {
    from: web3.defaultAccount,
    to: addressToSendTo,
    value: web3.toWei(1.0, "ether"),
    gas: gasAmountInWei
};

web3.eth.sendTransaction(transactionObject, function(err, data) {
    // if no err, transaction was success
});

For the gas value, you can estimate the gas needed like this

// note that `transactionObject` is the same as above but without the gas value
web3.eth.estimateGas(transactionObject, function(err, estimate) {
    transactionObject.gas = estimate;
});

If you have issues with gas not being enough, experiment with adding more. I generally multiply by 2, since it only uses what is needed and not the entire amount (since it is supposed to just be an estimate).

  • I am working on the android platform and java. My apologies for not stating that above – Stephen Mar 17 '18 at 15:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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