Skip to content

Latest commit

 

History

History
348 lines (310 loc) · 8.92 KB

File metadata and controls

348 lines (310 loc) · 8.92 KB

Keyper Agency Protocol

RPC Method

Auth: auth
QueryAddresses: query_addresses
SignTransaction: sign_transaction
SendTransaction: send_transaction
SignAndSendTransactoin: sign_and_send_transaction
signMessage: sign_message

Error Code

Rejected: 1001        # request is rejected
InvalidToken: 1002    # authorization failed
RemoteError: 1003     # error from indexer server
UnknownError: 1004    # other error

Request and Response

# Request
id: 1
jsonrpc: '2.0'
method: keypering_agency_method
params:

# success response:
id: 1
jsonrpc: '2.0'
result:

# error response:
id: 1
jsonrpc: '2.0'
code: error code
message: error message

Auth

  • Request
id: 1
jsonrpc: '2.0'
method: auth
params:
  description: 'Message with the authorization request'
  • Response
id: 1,
jsonrpc: '2.0'
result:
  token: token generated by keypering agency    # token used in other requests
  networkId: keypering connected network # ckb, ckb_test, ckb_dev

Query Addresses

  • Request
id: 1
jsonrpc: '2.0'
method: query_addresses
  • Response
id: 1,
jsonrpc: '2.0'
result:
  token: ...                  # optional
  userId: ...                 # user id, the uuid of keystore
  addresses:
    - address: address        # address string
      lockHash: lock hash     # lock script hash
      lockScript:             # lock script
        codeHash: code hash
        hashType: hash type
        args: args
      publicKey: public key   # public key
      lockScriptMeta:         # meta of lock script
        name: lock script name
        cellDeps:
          - outPoint:
              txHash: tx hash of lock script
              index: tx index of lock script
            depType: dep type
        headerDeps: []

Sign Transaction

  • Request
id: 1
jsonrpc: '2.0'
method: sign_transaction
params:
  tx:    # transaction to sign
    version: '0x0'
    cellDeps: []    # leave this empty since Keypering Agency provides cell deps
    inputs:
      - previousOutput:
          txHash: '0x29220d33fa282c4fdbade6e4af5589ab86edfa9b1a00f2a2ebef8adabdf4bbc0'
          index: '0x1'
        since: '0x0'
    outputs:
      - capacity: '0x2dd231b00'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
      - capacity: '0x3f2b47a51e'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
    outputsData:
      - 0x
      - 0x
    headerDeps: []
    witnesses:
      - lock: ''
        inputType: ''
        outputType: ''
  lockHash: '0xcf5ee0f83a06309618fc50f8cd1138f44de17ca812d1c6e3a665e6763d041e8f'    # lock hash used to search enabled lock scripts
  description: custom description
  inputSignConfig:                            # optional, null for all
    index: start index of witnesses to sign   # start index of witnesses to sign
    length: count of witnesses to sign        #-1 means all
  • Response
id: 1
jsonrpc: '2.0'
result:
  token: ...    # optional
  tx:           # signed transaction
    version: '0x0'
    cellDeps:
      - outPoint:
          txHash: '0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37'
          index: '0x0'
        depType: depGroup
    inputs:
      - previousOutput:
          txHash: '0x29220d33fa282c4fdbade6e4af5589ab86edfa9b1a00f2a2ebef8adabdf4bbc0'
          index: '0x1'
        since: '0x0'
    outputs:
      - capacity: '0x2dd231b00'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
      - capacity: '0x3f2b47a51e'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
    outputsData:
      - 0x
      - 0x
    headerDeps: []
    witnesses:
      - '0x5500000010000000550000005500000041000000dccc0b3ff641e85d5f5486b842cfe2b4cfd988d081ea5fa3fefec2deb639d9ee47b41fa55380738a1fd4507bc943bdded650f2c36a139b42dfe276e26c683a2e00'
    hash: '0xbc5ab6928193f783051fd61df30652724d6e8bea9b6cd13d4ee4a4aeae15042e'

Send Transaction

  • Request
id: 1
jsonrpc: '2.0'
method: send_transaction
params:
  tx:    # transaction to send
    version: '0x0'
    cellDeps:
      - outPoint:
          txHash: '0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37'
          index: '0x0'
        depType: depGroup
    inputs:
      - previousOutput:
          txHash: '0x29220d33fa282c4fdbade6e4af5589ab86edfa9b1a00f2a2ebef8adabdf4bbc0'
          index: '0x1'
        since: '0x0'
    outputs:
      - capacity: '0x2dd231b00'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
      - capacity: '0x3f2b47a51e'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
    outputsData:
      - 0x
      - 0x
    headerDeps: []
    witnesses:
      - '0x5500000010000000550000005500000041000000dccc0b3ff641e85d5f5486b842cfe2b4cfd988d081ea5fa3fefec2deb639d9ee47b41fa55380738a1fd4507bc943bdded650f2c36a139b42dfe276e26c683a2e00'
    hash: '0xbc5ab6928193f783051fd61df30652724d6e8bea9b6cd13d4ee4a4aeae15042e'
  • Response
id: 1
jsonrpc: '2.0'
result:
  token: ...                  # optional
  txHash: transaction hash    # transaction hash of sent transaction

Sign and Send Transaction

  • Request
id: 1
jsonrpc: '2.0'
method: sign_transaction
params:
  tx:    # transaction to sign and send
    version: '0x0'
    cellDeps: []    # leave this empty since Keypering Agency provides cell deps
    inputs:
      - previousOutput:
          txHash: '0x29220d33fa282c4fdbade6e4af5589ab86edfa9b1a00f2a2ebef8adabdf4bbc0'
          index: '0x1'
        since: '0x0'
    outputs:
      - capacity: '0x2dd231b00'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
      - capacity: '0x3f2b47a51e'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
    outputsData:
      - 0x
      - 0x
    headerDeps: []
    witnesses:
      - lock: ''
        inputType: ''
        outputType: ''
  lockHash: '0xcf5ee0f83a06309618fc50f8cd1138f44de17ca812d1c6e3a665e6763d041e8f'    # lock hash used to search enabled lock scripts
  description: custom description
  inputSignConfig:                            # optional, null for all
    index: start index of witnesses to sign   # start index of witnesses to sign
    length: count of witnesses to sign        #-1 means all
  • Response
id: 1
jsonrpc: '2.0'
result:
  token: ...                  # optional
  txHash: transaction hash    # sent transaction
  tx:                         # signed transaction
    version: '0x0'
    cellDeps:
      - outPoint:
          txHash: '0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37'
          index: '0x0'
        depType: depGroup
    inputs:
      - previousOutput:
          txHash: '0x29220d33fa282c4fdbade6e4af5589ab86edfa9b1a00f2a2ebef8adabdf4bbc0'
          index: '0x1'
        since: '0x0'
    outputs:
      - capacity: '0x2dd231b00'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
      - capacity: '0x3f2b47a51e'
        lock:
          codeHash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8'
          hashType: type
          args: '0xb27e5673ed8dd472e0f33dd0724d21e8cfdb8059'
        type: null
    outputsData:
      - 0x
      - 0x
    headerDeps: []
    witnesses:
      - '0x5500000010000000550000005500000041000000dccc0b3ff641e85d5f5486b842cfe2b4cfd988d081ea5fa3fefec2deb639d9ee47b41fa55380738a1fd4507bc943bdded650f2c36a139b42dfe276e26c683a2e00'
    hash: '0xbc5ab6928193f783051fd61df30652724d6e8bea9b6cd13d4ee4a4aeae15042e'

Sign Message

  • Request
id: 1
jsonrpc: '2.0'
method: sign_message
params:
  message: 'HelloCKB'
  address: 'ckt1qyqyeal9u0n9a0z54thrnqdthm0uy5l0lx9qejphk5'
  • Response
id: 1
jsonrpc: '2.0'
result:
  sig: "0x5ea1dcf9a8ea8efb613a897c8fb40375c44835fbf06562cf45c585f3cac38ef808d4a8fa722f0b48191db96acb09ae7e3c4b9ff0b106b725bdfdf9e561a4e89e00"