Skip to content

Instantly share code, notes, and snippets.

@luckyyang
Created May 27, 2020 13:58
Show Gist options
  • Save luckyyang/dd1166486b490f1bde5c7c2df5f2103f to your computer and use it in GitHub Desktop.
Save luckyyang/dd1166486b490f1bde5c7c2df5f2103f to your computer and use it in GitHub Desktop.

Keypering Protocol

Rich node RPC

ckb-rich-node RPC base on ckb-rpc and ckb-indexer-rpc.

Both RPCs are JSON-RPC protocol, more information can refer to ckb-rich-node.

Keypering API

Keypering API is WebSockets API for communication between Keypering and dApp base on plaintext.

  1. Establish link

When connecting to the WebSockets service for the first time, the server will return 40/keypering to identify keypering.

  1. Auth
  • Request
{"type": "auth", "origin": "http://demo.ckb.dapp"}
  • Response
{"type": "auth", "success": true, "message": "failure message",  "token": "xxxxxxxxxxxxxxxxxxxx"}
  1. Locks
  • Request
{"type": "locks", "token": "xxxxxxxxxxxxxxxxxxxx", "requestId": "xxxxxxxxxxxx"}
  • Response
{"type": "locks", "requestId": "xxxxxxxxxxxx", "success": true, "message": "failure message", "data": {"locks": [{"code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type""args": "0x8211f1b938a107cd53b6302cc752a6fc3965638d"}]}}
  1. Sign
  • Request

config is optional, default {"index": 0, "length": -1} identify full signature.

{"type": "sign", "token": "xxxxxxxxxxxxxxxxxxxx", "requestId": "xxxxxxxxxxxx", "data": {"target": "LOCK_HASH", "tx": TX_JSON, "config": {"index": 0, "length": -1}, "meta": "transaction metainfo"}}
  • Response
{"type": "sign", "requestId": "xxxxxxxxxxxx", "success": true, "message": "failure message", "data": {"tx": TX_JSON_WITH_SIGNATURE}}
  1. Sign and Send
  • Request
{"type": "sign_send", "token": "xxxxxxxxxxxxxxxxxxxx", "requestId": "xxxxxxxxxxxx", "data": {"target": "LOCK_HASH", "tx": TX_JSON, "config": {"index": 0, "length": -1}, "meta": "transaction metainfo"}}
  • Response
{"type": "sign_send", "requestId": "xxxxxxxxxxxx", "success": true, "message": "failure message", "data": {"hash": "TX_HASH"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment