4

I have a private ethereum network and a java process with communicates with a ethereum node with JSON RPC.

I need to add a transaction from java process by calling the sendRawTransaction RPC method.

How can I sign the transaction to be passed to a sendRawTransaction call?

1

You might find this answer helpful: How to transfer ether from one account to another using EthereumJ

It gives an example of using the EthereumJ java library to create a transaction and sign it with a private key. It uses the Transaction sign() method. The example goes on to submit the transaction via the library, but for your case you could serialize it and submit it to the sendRawTransaction RPC call.

Something like:

Transaction tx = new Transaction( ... );
tx.sign(senderKey);
String hex =  Hex.toHexString(tx.getEncoded())

See the example here: https://github.com/ethereum/ethereumj/blob/develop/ethereumj-core/src/main/java/org/ethereum/samples/SendTransaction.java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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