According to https://github.com/ethereum/wiki/wiki/JSON-RPC .There are only two method to sign messages eth_sign
and personal_sign
. I think they're meant to sign message rather than transaction.However,as there are no any other method to sign transaction I planned to try them out.
I tried:
personal.sign("{'to':'0x177daf75686029aea26afa49d4e771e73bfc379c','value':'1000000000000000000','gas':2000000}",”0xa4916400009dd529d9c647e3088e776faa0a7168","asdf”)
on geth console and have already unlocked account for signing address.Then it showed error message as :
Error: invalid argument 0: json: cannot unmarshal hex string without 0x prefix into Go value of type hexutil.Bytes
Thereafter, I used sha3 to convert the json to hex as:
personal.sign(web3.sha3("{'to':'0x177daf75686029aea26afa49d4e771e73bfc379c','value':'1000000000000000000','gas':2000000}"),”0xa4916400009dd529d9c647e3088e776faa0a7168","asdf”)
This returned 0xf1ed845050ba57e2ca7a233f958f59f28df2fd5bc7d28fa69eb822e56b589e4c01c992cd285e7207361b15acdf73317c9ddeedc383173f6a92a2d3e78aa4f2531c
in console.
I tried to confirm if it is valid signed transaction.Hence,I tried to push it on https://etherscan.io/pushTx.The site showed following error:
Unable to broadcast Tx : {"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"rlp: expected input string or byte for uint64, decoding into (types.Transaction)(types.txdata).AccountNonce"}}
.
Please can anyone give me solution how to generate signed transaction on geth console?
Best Answer
I don't know if that's a proper way of sending a raw transaction, but it works. Just tested it.
console:
Here's how I generated key pair and address: