ParityでJSON-RPCリクエストを送った際にParse errorが返ることがある。
現象
リクエスト
curl --data \
'{"method":"personal_unlockAccount","params":["0xbdb5232157860e22120cd9b9b847ca1024cdb95f","password", 0x3E8],"id":1,"jsonrpc":"2.0"}' \
-H "Content-Type: application/json" -X POST localhost:8545
エラー
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error"},"id":null}
原因と対策
hexの値は文字列として渡す必要がある。
修正後のリクエスト
curl --data \
'{"method":"personal_unlockAccount","params":["0xbdb5232157860e22120cd9b9b847ca1024cdb95f","password", "0x3E8"],"id":1,"jsonrpc":"2.0"}' \
-H "Content-Type: application/json" -X POST localhost:8545
環境
- Parity:
Parity/v1.11.0-beta-62ccdd7-20180508/x86_64-linux-gnu/rustc1.25.0
- Ubuntu 16.4 LTS:
Linux ip-10-1-0-38 4.4.0-1041-aws #50-Ubuntu SMP Wed Nov 15 22:18:17 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux