klaytn/caver-js

method personal_sign expects optional parameter

Closed this issue · 4 comments

Describe the bug
When I try to sign a message by using personal_sign (JSON RPC api) it expects password as a mandatory parameter though it is optional.

How to reproduce
Steps to reproduce the behavior:

  1. unlock the account
    curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["0xe825d3025a8094961486c0018d63998f8a4e9c96","password",99999],"id":1}' http://localhost:8551
  2. Sign using personal_sign
    curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"personal_sign","params":["0xdead","0xe825d3025a8094961486c0018d63998f8a4e9c96"],"id":1}' http://localhost:8551

Error
{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"missing value for required argument 2"}}

However with password it works
curl -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"personal_sign","params":["0xdead","0xe825d3025a8094961486c0018d63998f8a4e9c96", "password"],"id":1}' http://localhost:8551
Output
{"jsonrpc":"2.0","id":1,"result":"0xb1d70b843fec92b1c435baf0c94796b9f876d2986a3c220ebce143b05ae19d200a6744a2e5287298c5c0609199b988399ca7a8b0b830c403f47f74524bdcb8bb1b"}

Expected behavior
By right according to the documentation password is optional and it should work
https://docs.klaytn.com/dapp/json-rpc/api-references/personal#personal_sign

Attachments
Screenshot 2022-03-22 at 12 46 20 PM

Environment (please complete the following information)

  • caver-js : 1.8.0
  • macOS : 12.3

Additional context
In addition to the above issue. The same method throws error while connecting to the boabab testnet
{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"The method personal_newAccount does not exist/is not available"}}

Intention/Requirement
Sign using caver and metamask. Able to detect metamask and get balance using caver but unable to sign using caver. All other sign methods in caver requires private key. Since the app is connected to metamask and account is unlocked expecting caver's personal_sign to sign messages. web3.eth.personal.sign works

Hi, thank you for reporting an issue.

First, to use personal RPC call, EN node should allow personal RPC call via configuration.
But public EN does not support personal, so that's why The method personal_newAccount does not exist/is not available is occured.

And for last parameter, if you want to use personal_sign, you need to define password as a laster parameter.
The contents of klaytn docs are wrong, and i will fix this.

Thanks @jimni1222 . Is there an alternate way to sign using caver and metamask without private key and password ?
Intention is to sign using metamask wallet from a dApp. Similar to web3, it should connect to metamask where the account is unlocked and sign using caver.js.

I think you can try to use caver.rpc.klay.sign (documentation).

I will close this issue for now! if you have any issue, please feel free to reopen