Account Unlock – How to Unlock Account Using Private Key Instead of Password

etherjson-rpc

I am working with https://github.com/ethereum/wiki/wiki/JSON-RPC api + curl .

And implementing custom api using this php library:
https://github.com/Achse/geth-jsonrpc-php-client

below method is working fine for me for unlock before transaction:

$ curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["0x7642b...", "password", 3600],"id":67}' http://localhost:8545

But I want to unlock account using private key not by password. So is there any way to unlock account and do transaction using private key.

Best Answer

you can generate a raw transaction as described here or use myetherwallet to get the signed raw transaction and then call

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":[{raw_transaction}],"id":1}'

// Result
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}

as explained here

besides as @yogesh has mentioned in his comment bellow Ethereumjs build for browser can be used to build the rawtransaction (in client side).

Related Topic