Examples

It shows examples of using the Token/Wallet/Block APIs.

All APIs use HTTP POST to send and receive JSON data.

Address

Create an address

Users must have an address to store their tokens, like a bank account in a bank. To create an address, request as below.

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "1234",
    "method": "createAddress",
    "params": {
        "addInfo": "My first address"
    }
}
  • "jsonrpc" must be exactly "2.0".

  • "id" is an identifier established by the client application. Must contain a string.

  • "method" is a name of method to be invoked. To create an address, "createAddress" is used.

  • "params" holds the parameter values to be used during the invocation of the method. "addInfo" is the address name.

Response:

{
    "jsonrpc": "2.0",
    "id": "1234",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "address": "0x841dd0a424ba0ab63950a4c8ad11b33f34deac64",
            "mnemonic": "miracle anchor zebra brush talent broom pig broom news hammer suit brick",
            "secretKey": "d0c48b4d6972bf8d4110f81d5dd8ac1c"
        }
    }
}
  • "id" is the same value of the request.

  • Address "0x841dd0a424ba0ab63950a4c8ad11b33f34deac64" is created.

  • "mnemonic" is keywords used when restoring a secret key when it is lost. The user should record this somewhere for later.

  • "secretKey" should be saved in the client application. If you lose it, you cannot use this address.

If you want to check your address,

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "1235",
    "method": "getAddressInfo",
    "params": {
        "address": "0x841dd0a424ba0ab63950a4c8ad11b33f34deac64"
    }
}

Response:

{
    "jsonrpc": "2.0",
    "id": "1235",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "address": "0x841dd0a424ba0ab63950a4c8ad11b33f34deac64",
            "addInfo": "My first address"
        }
    }
}

ERC20

Transfer ERC20 token

Tokens are identified by contract address. Token generation is managed by the server, not by the client. The following tokens are defined.

Token transfer takes place in 4 steps.

First, a temporary key is issued to secure the transfer.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "1234",
    "method": "net_getTempKey",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "keyType": "transfer"
    }
}
  • "address" is the your sender address.

  • "keyType" should be "transfer".

Response:

{
    "jsonrpc": "2.0",
    "id": "1234",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "tempKey": "c3b915aba82d31aa7f505739ee323db0"
        }
    }
}
  • "tempKey" is used during transfer.

Second, create the signature of the message to secure the message.

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "1234",
    "method": "signData",
    "params": {
        "address": "0x841dd0a424ba0ab63950a4c8ad11b33f34deac64",
        "data": "0ef6b88023386ac2691ebc50e6ab8c651326524ac7932b2c88c8349cc0b5d21f",
        "tempKey": "c3b915aba82d31aa7f505739ee323db0",
        "hashKey": "5df34c6abc72e6d96e4499f6b1999e43c146a43000813eb7154c87c1eb3dc619"
    }
}
  • "address" is the sender address.

  • "tempKey" is the temp key issued in the first step.

  • "hashKey" is the hash value made from the the temp key and the secret key of the sender address. For example, hash(['c3b915aba82d31aa7f505739ee323db0', 'd0c48b4d6972bf8d4110f81d5dd8ac1c']) => '5df34c6abc72e6d96e4499f6b1999e43c146a43000813eb7154c87c1eb3dc619'. The hash function is defined below in Dart. This function will be used repeatedly.

/// Dart
import 'package:crypto/crypto.dart';
String hash(List<String> v) => sha256.convert(utf8.encode(v.join('|'))).toString();
  • "data" is the hash value made from the contract address, your address (sender), the recipient address, the transfer amount, the temp key, and the hash key. For example, hash(['0x1a007ca3d881c14269f956c6e4b734095bf450a7', '0x841dd0a424ba0ab63950a4c8ad11b33f34deac64', '0x191f06333602d2f5296e1aa83e3166454032adab', "1", "c3b915aba82d31aa7f505739ee323db0", "5df34c6abc72e6d96e4499f6b1999e43c146a43000813eb7154c87c1eb3dc619"]) => '0ef6b88023386ac2691ebc50e6ab8c651326524ac7932b2c88c8349cc0b5d21f'

Response:

{
    "jsonrpc": "2.0",
    "id": "1234",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "304502203ee4b7410b058c718ae52423cde25f4df68b4ce49255c4a6f34ae368c3f0a3690221009332445fcb1717588063a098882bc6ff17e887b76f6fac46ca0cfdec0e1e2595"
        }
    }
}
  • "signedData" is used for the signature of the message.

Third, transfer a token.

Request: https://test-api.protx.io/token ****

{
    "jsonrpc": "2.0",
    "id": "1234",
    "method": "erc20_transfer",
    "params": {
        "contractAddress": "0x1a007ca3d881c14269f956c6e4b734095bf450a7",
        "sender": "0x841dd0a424ba0ab63950a4c8ad11b33f34deac64",
        "toAddress": "0x191f06333602d2f5296e1aa83e3166454032adab",
        "amount": "1",
        "tempKey": "c3b915aba82d31aa7f505739ee323db0",
        "hashKey": "5df34c6abc72e6d96e4499f6b1999e43c146a43000813eb7154c87c1eb3dc619",
        "signature": "3044022036d634a588a4582539465d8c4849303ed5acee11ba6e3772649ba6e442c1d25c022016902d4dd83bcedca25ef7e4e530d19f08afba77a1c2d10fe25d225ae2eb7f79",
        "comment": "Transfer"
    }
}
  • "signature" is the signed data in the second step.

  • "comment" is not included in the signature.

Response:

{
    "jsonrpc": "2.0",
    "id": "57096",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0x50d0b07cd332b08b15ec071c9bf00cd6b926f43b2ffd1bc62e7f3254033e94ee"
        }
    }
}
  • "transactionId" is returned.

Forth, token transfer takes time. Wait until it is written to the blockchain.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "57266",
    "method": "net_getTransactionStatus",
    "params": {
        "transactionId": "0x50d0b07cd332b08b15ec071c9bf00cd6b926f43b2ffd1bc62e7f3254033e94ee"
    }
j

Response:

{
    "jsonrpc": "2.0",
    "id": "57266",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "status": -1,
            "revertReason": ""
        }
    }
}

Or

{
    "jsonrpc": "2.0",
    "id": "59336",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "status": 1,
            "revertReason": ""
        }
    }
}
  • A status of -1 indicates that the transaction is still in progress, and 0 or 1 indicates that the transaction is complete. (1: success, 0: error).

Waits by periodically calling net_getTransactionStatus until status is not -1.

Get ERC20 balance

Check the balance of a specific token in the address.

Request: https://test-api.protx.io/token ****

{
    "jsonrpc": "2.0",
    "id": "37026",
    "method": "erc20_getBalance",
    "params": {
        "contractAddress": "0x1a007ca3d881c14269f956c6e4b734095bf450a7"
        "address": "0x841dd0a424ba0ab63950a4c8ad11b33f34deac64",
    }
}

Response:

{
    "jsonrpc": "2.0",
    "id": "37026",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "balance": "99"
        }
    }
}

ERC721 (NFT)

Transfer ERC721 (NFT) token

The ERC721 token creation, minting, and transfer are managed by the server. The client only handlles token approval. The following tokens are defined.

When you mint the product through the server (a separate API will be provided), you will receive the contract address and token ID.

In order to put a product on the NFT market, the authority of the product must be delegated to the market. At this time, the approval method is used. The approval method is called similar to the transfer method.

First, get a temporary key.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "53494",
    "method": "net_getTempKey",
    "params": {
        "address": "0xd839a7e8872a2624fc9d84eee63bb1eca8ee9be9",
        "keyType": "approve"
    }
}
  • "address" is the address where your NFT is stored.

  • "keyType" should be "approve".

Response:

{
    "jsonrpc": "2.0",
    "id": "53494",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "tempKey": "ae1b64e6a1a29d9b91ef7515dfe74c4d"
        }
    }
}

Second, get the message signature.

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "54079",
    "method": "signData",
    "params": {
        "hashKey": "02d8168679b03d74902159e2e1782d2a0644408acb01791023c858dc8788df11",
        "address": "0xd839a7e8872a2624fc9d84eee63bb1eca8ee9be9",
        "data": "5b69d60a7fec498b9f3d24ef06b4cb323c7d0606e4606edad19065c3c024f578",
        "tempKey": "ae1b64e6a1a29d9b91ef7515dfe74c4d"
    }
}
  • "hashKey" is the hash value made from the the temp key and the secret key of the your address. For example, hash(['ae1b64e6a1a29d9b91ef7515dfe74c4d', 'b5dc981ece0925ecf56e490727bce577']) => '02d8168679b03d74902159e2e1782d2a0644408acb01791023c858dc8788df11'. "b5dc981ece0925ecf56e490727bce577" is the secret key of the your address.

  • "data" is the hash value made from the contract address, your address (sender), the market address (spender), the token ID, the temp key, and the hash key. For example, hash(['0xa408c647676f01c1463174019ddacdc49837097b', '0xd839a7e8872a2624fc9d84eee63bb1eca8ee9be9', '0x6a39630bd5986e73fe181938c6097958127c16c4', "2", "ae1b64e6a1a29d9b91ef7515dfe74c4d", "02d8168679b03d74902159e2e1782d2a0644408acb01791023c858dc8788df11"]) => '5b69d60a7fec498b9f3d24ef06b4cb323c7d0606e4606edad19065c3c024f578'. "0x6a39630bd5986e73fe181938c6097958127c16c4" is the market address.

Response:

{
    "jsonrpc": "2.0",
    "id": "54079",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "3046022100c21b658831e1d8955fd92fb937c0c5d39ceb2f72522a0667fdff685764920478022100fa38a36d9e2b6cac80e39723ac79af4386ad466e1afd019a50149588c3a78de2"
        }
    }
}

Third, delegate the ownership of the product to the market.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "54157",
    "method": "erc721_approve",
    "params": {
        "hashKey": "02d8168679b03d74902159e2e1782d2a0644408acb01791023c858dc8788df11",
        "tokenId": "2",
        "sender": "0xd839a7e8872a2624fc9d84eee63bb1eca8ee9be9",
        "spender": "0x6a39630bd5986e73fe181938c6097958127c16c4",
        "signature": "3046022100c21b658831e1d8955fd92fb937c0c5d39ceb2f72522a0667fdff685764920478022100fa38a36d9e2b6cac80e39723ac79af4386ad466e1afd019a50149588c3a78de2",
        "contractAddress": "0xa408c647676f01c1463174019ddacdc49837097b",
        "comment": "Put on the market",
        "tempKey": "ae1b64e6a1a29d9b91ef7515dfe74c4d"
    }
}
  • "sender" is your address which stores your NFT.

  • "spender" is the market address.

Response:

{
    "jsonrpc": "2.0",
    "id": "54157",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0xf9348011be7423261ca2c74208f876a1a4a3cd6dcd3038414a131bd247d6b783"
        }
    }
}

Forth, token approval takes time. Wait until it is finished.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "54238",
    "method": "net_getTransactionStatus",
    "params": {
        "transactionId": "0xf9348011be7423261ca2c74208f876a1a4a3cd6dcd3038414a131bd247d6b783"
    }
}

Response:

{
    "jsonrpc": "2.0",
    "id": "56316",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "status": 1,
            "revertReason": ""
        }
    }
}
  • A status of -1 indicates that the transaction is still in progress, and 0 or 1 indicates that the transaction is complete. (1: success, 0: error).

Waits by periodically calling net_getTransactionStatus until status is not -1.

Swap

Get token swap list

To get a list of swappable tokens, use swap_getPairList. Token swap list management is done by the server.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0"
    "id": "85551",
    "method": "swap_getPairList",
}

Response:

{
    "jsonrpc": "2.0",
    "id": "85551",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": [
            {
                "pairAddress": "0x294e47341f7da34a6d8187ecbc4ff206d6ca212f",
                "token0": "0x0d183c9a4d9b2c503c049ffc687436b35c31ea3a",
                "token1": "0x4883c1d966d103485f97f548a0cb1fb117388af0",
                "symbol0": "TOK1",
                "symbol1": "TOK2",
                "amount0": "1",
                "amount1": "10"
            }
        ]
    }
}
  • Swap between TOK1 and TOK2 is possible.

Get estimate of swap

You can get an estimate of the amount you can receive when swapping.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "86197",
    "method": "swap_getAmountOut",
    "params": {
        "tokenIn": "0x0d183c9a4d9b2c503c049ffc687436b35c31ea3a",
        "tokenOut": "0x4883c1d966d103485f97f548a0cb1fb117388af0",
        "amountIn": "0.1",
        "sender": "0x6a39630bd5986e73fe181938c6097958127c16c4"
    }
}
  • "tokenIn" and "tokenOut" are the token contract addresses.

  • You want to swap "amountIn" from "tokenIn" to "tokenOut".

  • "sender" is your address storing "tokenIn".

Response:

{
    "jsonrpc": "2.0",
    "id": "86197",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "amountIn": "0.1",
            "amountOut": "0.405288228265375695"
        }
    }
}
  • You can get 0.405288228265375695 of tokenOut.

Swap tokens

To swap tokens, there are two steps.

First, you must entrust (approve) your token. To call this method, as in the case of transfer, the temp key is obtained, the message signature is obtainded, after then the method can is called.

Get a temp key.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "86255",
    "method": "net_getTempKey",
    "params": {
        "address": "0x6a39630bd5986e73fe181938c6097958127c16c4",
        "keyType": "approve"
    }
}
  • "address" is your address.

  • "keyType" should be "approve".

Response:

{
    "jsonrpc": "2.0",
    "id": "86255",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "tempKey": "b215f78617e0e5559042971c8e284133"
        }
    }
}

Get the signature of the message.

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "86287",
    "method": "signData",
    "params": {
        "address": "0x6a39630bd5986e73fe181938c6097958127c16c4",
        "tempKey": "b215f78617e0e5559042971c8e284133",
        "hashKey": "33f82dc02a98428690b41820970bfeefff7294fcb432408ed8ad924baf874fe1",
        "data": "d62cd64946e2522dc7963a7bcabf5d927998bbeea10d96732b79aa793ecf9b8a"
    }
}
  • "hashKey" is hash(temp key, your address's secret key).

  • "data" is hash(tokenIn contract address, your address, amount, "tempKey", "hashKey").

Resonse:

{
    "jsonrpc": "2.0",
    "id": "86287",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "304602210088ae728b0bc33b7416d73c4b4e04be59bf9da45ad1037799f1b7e4b49a1a16a4022100da66160775e9a99dbd8e02aae98ad7b0eb45a0c0ab55c9fbe6d604c320a0aa31"
        }
    }
}

Approve the token amount

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "86354",
    "method": "swap_approve",
    "params": {
        "contractAddress": "0x0d183c9a4d9b2c503c049ffc687436b35c31ea3a",
        "sender": "0x6a39630bd5986e73fe181938c6097958127c16c4",
        "amount": "0.1",
        "comment": "Approve to swap",
        "tempKey": "b215f78617e0e5559042971c8e284133",
        "hashKey": "33f82dc02a98428690b41820970bfeefff7294fcb432408ed8ad924baf874fe1",
        "signature": "304602210088ae728b0bc33b7416d73c4b4e04be59bf9da45ad1037799f1b7e4b49a1a16a4022100da66160775e9a99dbd8e02aae98ad7b0eb45a0c0ab55c9fbe6d604c320a0aa31"
    }
}
  • "contractAddress" is the tokenIn contract address.

  • "sender" is your address.

  • "tempKey", "hashKey", and "signature" are obtained in the previous steps.

Response:

{
    "jsonrpc": "2.0",
    "id": "86354",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0x0a32339b56022e31aa1f3a5162d4e4a581a3d28505ac7c84b05fdd5c347bb61f"
        }
    }
}

Wait for it to complete.

Request: https://test-api.protx.io/token****

{
    "method": "net_getTransactionStatus",
    "id": "86420",
    "jsonrpc": "2.0",
    "params": {
        "transactionId": "0x0a32339b56022e31aa1f3a5162d4e4a581a3d28505ac7c84b05fdd5c347bb61f"
    }
}

Response:

{
    "jsonrpc": "2.0",
    "id": "89531",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "status": 1,
            "revertReason": ""
        }
    }
}

Second, swap tokens.

Get a temp key.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "89561",
    "method": "net_getTempKey",
    "params": {
        "address": "0x6a39630bd5986e73fe181938c6097958127c16c4",
        "keyType": "swap"
    }
}
  • "address" is your address.

  • "keyType" should be "swap".

Response:

{
    "jsonrpc": "2.0",
    "id": "89561",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "tempKey": "57a2b588f8b9634f53a322cdf1edfb05"
        }
    }
}

Get the signature of the message.

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "89597",
    "method": "signData",
    "params": {
        "address": "0x6a39630bd5986e73fe181938c6097958127c16c4",
        "hashKey": "829f93bc755e5928a13edb69d9bf81130db4f6d4637c59c2aa9923af9ac1a93e",
        "tempKey": "57a2b588f8b9634f53a322cdf1edfb05",
        "data": "0758e1bd89b0cb38b38ca6f74e601a3eb258f33eeedcf0ba3531c1d624f6968a"
    }
}
  • "hashKey" is hash(temp key, your address's secret key).

  • "data" is hash(tokenIn amount, tokenOut amount, tokenIn contract address, your address, "tempKey", "hashKey").

Resonse:

{
    "jsonrpc": "2.0",
    "id": "89597",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "3045022100946bd7860fe667b247692d50449135864428c17e0d50e42175a8b701ac8ed11702205a69e0f03684842906aed52b1c030dc686030806926ad1a7c3aa3c80291c37ff"
        }
    }
}

Swap tokens.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "89626",
    "method": "swap_tokenToToken",
    "params": {
        "amountIn": "0.1",
        "tokenIn": "0x0d183c9a4d9b2c503c049ffc687436b35c31ea3a",
        "tokenOut": "0x4883c1d966d103485f97f548a0cb1fb117388af0",
        "sender": "0x6a39630bd5986e73fe181938c6097958127c16c4",
        "comment": "Swap",
        "tempKey": "57a2b588f8b9634f53a322cdf1edfb05",
        "hashKey": "829f93bc755e5928a13edb69d9bf81130db4f6d4637c59c2aa9923af9ac1a93e",
        "signature": "3045022100946bd7860fe667b247692d50449135864428c17e0d50e42175a8b701ac8ed11702205a69e0f03684842906aed52b1c030dc686030806926ad1a7c3aa3c80291c37ff"
    }
}
  • "tokenIn" and "tokenOut" are the contract addresses.

  • "sender" is your address.

  • "tempKey", "hashKey", and "signature" are obtained in the previous steps.

Response:

{
    "jsonrpc": "2.0",
    "id": "89626",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0xc0a11b0b743d060672f00bb7c8386af252d793162b6aee233109c2daaf054173"
        }
    }
}

Wait for it to complete.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "91789",
    "method": "net_getTransactionStatus",
    "params": {
        "transactionId": "0xc0a11b0b743d060672f00bb7c8386af252d793162b6aee233109c2daaf054173"
    }
}

Response:

{
    "jsonrpc": "2.0",
    "id": "91789",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "status": 1,
            "revertReason": ""
        }
    }
}

Staking

Get staking list

Request: https://test-api.protx.io/block ****

{
    "jsonrpc": "2.0",
    "id": "55900",
    "method": "getStakingV1List",
    "params": {
        "pageNumber": 1,
        "pageSize": 10,
        "order": 1,
        "stakingTimeFilter": 1666000700819,
    }
}
  • If order is 1, it is in ascending order, otherwise in descending order.

  • If you put the current time in the "stakingTimeFilter", only the currently valid staking list is retrieved.

/// In dart
var stakingTimeFilter = DateTime.now().millisecondsSinceEpoch;

Response:

{
    "jsonrpc": "2.0",
    "id": "55900",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "pageNumber": 1,
            "pageSize": 10,
            "totalPages": 1,
            "totalElements": 1,
            "list": [
                {
                    "contractAddress": "0x82fb521a90b8ac242801e4603434968e2cdd9920",
                    "owner": "0x5f619702528e9de7f5a4a233cd1896902385e705",
                    "stakingToken": "0x5f748cff221bf63bdadf33cd2678093930e7fb2a",
                    "rewardToken": "0x3ff720bf49f69a61fd2c9a19a5b9a33ed5a59555",
                    "rewardRate": 100,
                    "limitStakingTime": 1666427295713,
                    "limitRewardTime": 1666427295713,
                    "txId": "0x81c0ae9709ea292d4546adb991fe13be4d06f3190c35641e9870e9adea493150",
                    "blockNumber": 3621918,
                    "txTime": "2022-10-17T17:28:38"
                }
            ]
        }
    }
}
  • "contractAddress" is the address to be used for staking later. Hereafter, we will refer to it as "stakingAddress".

  • "stackingToken" and "rewardToken" are the contract addresses. In UI, the token symbol corresponding to the contract address should be shown.

  • "limitStakingtime" and "limitRewardTime" are the number of seconds that have elapsed since January 1st, 1970 00:00:00 UTC.

  • "rewardRate" is the interest rate per second. The unit is 0.0000000000000000001. If the rewardRate is "10000000000", then 10000000000 * 3600 * 24 * 365 = 3.1536% per year.

Start staking

First, before staking, you need to approve your tokens to the staking address.

Get a temp key.

Request: https://test-api.protx.io/tokenh

{
    "jsonrpc": "2.0",
    "id": "10029",
    "method": "net_getTempKey",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "keyType": "approve"
    }
}
  • "address" is your address.

  • "keyType" should be "approve".

Response:

{
    "jsonrpc": "2.0",
    "id": "10029",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "tempKey": "a694f888d7e45aea7773948de35437ef"
        }
    }
}

Get the message signature.

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "10722",
    "method": "signData",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "tempKey": "a694f888d7e45aea7773948de35437ef",
        "hashKey": "4a935c6b118b3e1a432147d88f7bd29fce5c976fd02c28870274664d10c6167d",
        "data": "57a4ad402f7abc6f93bfafd5623ac68545df82e12686d9adb6b11e1e0d9cf4cf"
    }
}
  • "address" is your address.

  • "hashKey" is hash(temp key, your address's secret key)

  • "data" is hash(contract address of the token to be entrusted to the staking address, your address, staking address, amount, "tempKey", "hashKey")

Response:

{
    "jsonrpc": "2.0",
    "id": "10722",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "304402205007a96f671808d1c09daad726621be5fac7e04e83d75abace1aa7301677d9bc022046c43cf4853a7f38dce3345a7a132a3b73c3a4aa05b656003d583af5af166de0"
        }
    }
}

Approve your tokens to the staking address.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "10788",
    "method": "erc20_approve",
    "params": {
        "contractAddress": "0x5f748cff221bf63bdadf33cd2678093930e7fb2a",
        "sender": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "spender": "0x82fb521a90b8ac242801e4603434968e2cdd9920",
        "amount": "1",
        "comment": "Approve",
        "tempKey": "a694f888d7e45aea7773948de35437ef",
        "hashKey": "4a935c6b118b3e1a432147d88f7bd29fce5c976fd02c28870274664d10c6167d",
        "signature": "304402205007a96f671808d1c09daad726621be5fac7e04e83d75abace1aa7301677d9bc022046c43cf4853a7f38dce3345a7a132a3b73c3a4aa05b656003d583af5af166de0"
    }
}
  • "contractAddress" is the token contract address to be deposited to the staking address.

  • "sender" is your address.

  • "spender" is the staking address.

  • "amount" is the amount you want to deposit at the staking address. It must be less than the amount you currently have in your address).

Response:

{
    "jsonrpc": "2.0",
    "id": "10788",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0xecc5fc9aba68fe4c04964505213359d6c9edd5cc5d471f2caca94cbfec1c274a"
        }
    }
}

Wait for it to complete using net_getTransactionStatus.

Second, start staking.

Get a temp key.

Request: https://test-api.protx.io/token ****

{
    "jsonrpc": "2.0",
    "id": "95866",
    "method": "net_getTempKey",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "keyType": "stake"
    }
}
  • "address" is your address.

  • "keyType" should be "stake".

Response:

{
    "jsonrpc": "2.0",
    "id": "95866",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "tempKey": "52f6f4b228b38b0602e659ceee45e784"
        }
    }
}

Get the message signature

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "96450",
    "method": "signData",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "tempKey": "52f6f4b228b38b0602e659ceee45e784",
        "hashKey": "2c6219ee0ba6889bca7767ad686fedc12a48d364590ad3c14e34574ac18ce23e",
        "data": "ed3747837d66d5f003548abdea104b2a81170b68a859080ec440054d5366f989"
    }
}
  • "hashKey" is hash(temp key, address's secret key).

  • "dataKey" is hash(staking address, your address, amount, "tempKey", "hashKey").

Response:

{
    "jsonrpc": "2.0",
    "id": "96450",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "3045022100bd4a0fefdde88497f67271eaa9c828b139e1a5df3845faf2d7bea70f381123e40220668a2bfcee0a160b74ea975e57529f826cb7d59ce284232383506152a9212575"
        }
    }
}

Start staking.

Request: https://test-api.protx.io/token****

{
    "jsonrpc": "2.0",
    "id": "24225",
    "method": "stakingV1_stake",
    "params": {
        "stakingAddress": "0x82fb521a90b8ac242801e4603434968e2cdd9920",
        "sender": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "amount": "1",
        "comment": "Stake",
        "tempKey": "52f6f4b228b38b0602e659ceee45e784",
        "hashKey": "2c6219ee0ba6889bca7767ad686fedc12a48d364590ad3c14e34574ac18ce23e",
        "signature": "3045022100bd4a0fefdde88497f67271eaa9c828b139e1a5df3845faf2d7bea70f381123e40220668a2bfcee0a160b74ea975e57529f826cb7d59ce284232383506152a9212575"
    }
}
  • "stakingAddress" is the address to be used for staking.

  • "sender" is your address.

Response:

{
    "jsonrpc": "2.0",
    "id": "24225",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0xe559e76068b177747a512c0fa82800cc184c76f57603a9ffd7768e50383146e8"
        }
    }
}

Wait for it to complete using net_getTransactionStatus.

Check the current staking status

Get the token amount deposited in the staking address.

Request: https://test-api.protx.io/token ****

{
    "jsonrpc": "2.0",
    "id": "36392",
    "method": "stakingV1_getStaked",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "stakingAddress": "0x82fb521a90b8ac242801e4603434968e2cdd9920"
    }
}
  • "address" is your address.

  • "stakingAddress" is the address to be used for staking.

Response:

{
    "jsonrpc": "2.0",
    "id": "36392",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "balance": "1"
        }
    }
}

Find the amount received as a reward so far.

Request: https://test-api.protx.io/token ****

{
    "jsonrpc": "2.0",
    "id": "36465",
    "method": "stakingV1_getEarned",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "stakingAddress": "0x82fb521a90b8ac242801e4603434968e2cdd9920"
    }
}
  • "address" is your address.

  • "stakingAddress" is the address to be used for staking.

Response:

{
    "jsonrpc": "2.0",
    "id": "36465",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "balance": "0.0000000000000012"
        }
    }
}
  • The current reward is 0.0000000000000012.

Withdraw

First, withdraw the token amount I deposited to the staking address.

Get a temp key

Request: https://test-api.protx.io/token

{
    "jsonrpc": "2.0",
    "id": "36492",
    "method": "net_getTempKey",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "keyType": "withdraw"
    }
}
  • "address" is your address.

  • "keyType" should be "withdraw".

Response:

{
    "resultCode": "200",
    "resultMessage": "Success",
    "resultData": {
        "tempKey": "464317e9051c036bae5d55879420ec59"
    }
}

Get the message signature

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "36525",
    "method": "signData",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "tempKey": "464317e9051c036bae5d55879420ec59",
        "hashKey": "17c48c9425c19bcb659f943921f7ec150e10f85bb0ff2e733c438560c5f74898",
        "data": "ba2c07102047695df0c352d1a43bc277ed88ac27b5eafcdb2c027c13c9df475e"
    }
}
  • "tempKey" is hash(temp key, address's secret key).

  • "data" is hash(staking address, your address, amount, "tempKey", "hashKey").

Response:

{
    "jsonrpc": "2.0",
    "id": "36525",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "3046022100c52683d4b2318a1380f002da07de67e0fc3d8bcb6e39ccc15b29b1df533c68af022100ef3fcd0c1d11614e06c77f280202f0fc87c1dff8be5ef499a85b8c4256398895"
        }
    }
}

Withdraw the deposited amount.

Request: https://test-api.protx.io/token****

{
    "method": "stakingV1_withdraw",
    "id": "36552",
    "jsonrpc": "2.0",
    "params": {
        "stakingAddress": "0x82fb521a90b8ac242801e4603434968e2cdd9920",
        "sender": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "amount": "1",
        "comment": "Withdraw",
        "tempKey": "464317e9051c036bae5d55879420ec59",
        "hashKey": "17c48c9425c19bcb659f943921f7ec150e10f85bb0ff2e733c438560c5f74898",
        "signature": "3046022100c52683d4b2318a1380f002da07de67e0fc3d8bcb6e39ccc15b29b1df533c68af022100ef3fcd0c1d11614e06c77f280202f0fc87c1dff8be5ef499a85b8c4256398895"
    }
}
  • "stakingAddress" is the address to be used for staking.

  • "sender" is your address.

  • "amount" is your deposited amount to the staking address.

Response:

{
    "jsonrpc": "2.0",
    "id": "36552",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0xc9920e01b32f7bc52a12c6342d2b8f8ad39ec72d9c0728a57552e0ca8857c8b9"
        }
    }
}

Wait for it to complete using net_getTransactionStatus.

Second, in order to get the reward earned through staking back, it is similar to the withdrawal process.

Get a temp key.

Request: https://test-api.protx.io/token

{
    "jsonrpc": "2.0",
    "id": "38723",
    "method": "net_getTempKey",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "keyType": "claimReward"
    }
}
  • "address" is your address.

  • "keyType" should be "claimReward".

Response:

{
    "jsonrpc": "2.0",
    "id": "38723",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "tempKey": "effeba77d6c04223d4a381a1dffa7d3f"
        }
    }
}

Get the message signature.

Request: https://test-api.protx.io/wallet****

{
    "jsonrpc": "2.0",
    "id": "38757",
    "method": "signData",
    "params": {
        "address": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "tempKey": "effeba77d6c04223d4a381a1dffa7d3f",
        "hashKey": "0e6f8b6c0f89cd1427bd7cdcd69b337a50a535f70f0a8580c4f1484ae267129d",
        "data": "05eadc9b44605d6ef54ff3d62bb909e29ba4f32eaea02e2128472cb5ecd0d7cf"
    }
}
  • "address" is your address.

  • "hashKey" is hash(temp key, address's secret key).

  • "data" is hash(staking address, your address, "tempKey", "hashKey").

Response:

{
    "jsonrpc": "2.0",
    "id": "38757",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "signedData": "30440220230f62ac0d2700ce8af8be2fb29fcc8e9337f8c64b3df20c9b0df1192324cb660220632c491f2c105856961dfd571dd191a9a678758275c251f48c56b7cfae37b228"
        }
    }
}

Get the reward.

Request: https://test-api.protx.io/token ****

{
    "jsonrpc": "2.0",
    "id": "38788",
    "method": "stakingV1_claimReward",
    "params": {
        "stakingAddress": "0x82fb521a90b8ac242801e4603434968e2cdd9920",
        "sender": "0x5f619702528e9de7f5a4a233cd1896902385e705",
        "comment": "Claim reward",
        "tempKey": "effeba77d6c04223d4a381a1dffa7d3f",
        "hashKey": "0e6f8b6c0f89cd1427bd7cdcd69b337a50a535f70f0a8580c4f1484ae267129d",
        "signature": "30440220230f62ac0d2700ce8af8be2fb29fcc8e9337f8c64b3df20c9b0df1192324cb660220632c491f2c105856961dfd571dd191a9a678758275c251f48c56b7cfae37b228"
    }
}
  • "stakingAddress" is the address to be used for staking.

  • "sender" is your address.

Response:

{
    "jsonrpc": "2.0",
    "id": "38788",
    "result": {
        "resultCode": "200",
        "resultMessage": "Success",
        "resultData": {
            "transactionId": "0x1e3539d4de4b6ebe9e15e03898e0759fed71d68c35804c29523eb1b1031f6860"
        }
    }
}

Wait for it to complete using net_getTransactionStatus.

DID

Create decentralized identifier (DID)

Request: https://test-auth.protx.io/v2/did/create-did****

{
    "alias": "4700634FB09E0019",
    "address": "0x38b45217e81548733f9fd7443ecfe4ea6b5725cf",
    "secretKey": "********"
}
  • "alias" is an alias for identifying a DID.

  • "address" and "secretKey" are your address information created through the token API.

Response:

{
  "controllerKeyId": "0x38b45217e81548733f9fd7443ecfe4ea6b5725cf",
  "provider": "did:ethr",
  "keys": [
    {
      "kid": "0x38b45217e81548733f9fd7443ecfe4ea6b5725cf",
      "kms": "protx-kms",
      "type": "Secp256k1",
      "publicKeyHex": "0x38b45217e81548733f9fd7443ecfe4ea6b5725cf",
      "privateKeyHex": "",
      "meta": {
        "algorithms": [
          "ES256K",
          "ES256K-R",
          "eth_signTransaction",
          "eth_signTypedData",
          "eth_signMessage"
        ],
        "secretKey": "********"
      }
    }
  ],
  "alias": "4700634FB09E0019",
  "services": [],
  "did": "did:ethr:0x38b45217e81548733f9fd7443ecfe4ea6b5725cf"
}
  • The response body is the DID body.

Create verifiable credentials (VCs)

Because this is the credentials used by this system, the JWT authenticated by /auth/auth-user in advance is needed.

Request: https://test-auth.protx.io/v2/did/create-vc****

curl -X 'POST' \
  'https://test-auth.protx.io/v2/did/create-vc' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0Iiwicm9sZSI6IlJPTEVfVVNFUiIsImV4cCI6MTY2ODkyMzY5MSwidXNlciI6IjQ3MDA2MDM2NDRCNzAwMDQiLCJpYXQiOjE2NjYzMzE2OTF9.c2BMNGbTUNV6HQAIBy9nHOTEK8nZOex1r-ntO3KLlNY' \
  -H 'Content-Type: application/json' \
  -d '{
  "holder": "did:ethr:0x38b45217e81548733f9fd7443ecfe4ea6b5725cf",
  "issuer": "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4",
  "userInfo": {
     "name": "Hong"
  }
}'
  • "holder" is your DID.

  • "issuer" is the issuer DID provided by this authentication system.

  • Provides additional information to "userInfo" in key/value format.

Response:

{
  "credentialSubject": {
    "name": "Hong",
    "sub": "test",
    "id": "did:ethr:0x38b45217e81548733f9fd7443ecfe4ea6b5725cf"
  },
  "issuanceDate": "2022-10-21T05:56:06.000Z",
  "proof": {
    "type": "JwtProof2020",
    "jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiUHJvZmlsZSJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJuYW1lIjoiSG9uZyIsInN1YiI6InRlc3QifX0sInN1YiI6ImRpZDpldGhyOjB4MzhiNDUyMTdlODE1NDg3MzNmOWZkNzQ0M2VjZmU0ZWE2YjU3MjVjZiIsIm5iZiI6MTY2NjMzMTc2NiwiaXNzIjoiZGlkOmV0aHI6MHhkMjg0Y2RjOTY0YWY4YTAxZDgyZDBjYWE3ZGVlYmE4Mjc4NWI1NGY0In0.IvrseTkX-lnadHg7TrPcBaTC5utYIr72nbQRgdNS_jwSPy4fypUxu7_2xaJw1IqHy71-uTp1B52hAz7ZeRb89g"
  },
  "type": [
    "VerifiableCredential",
    "Profile"
  ],
  "@context": [
    "https://www.w3.org/2018/credentials/v1"
  ],
  "issuer": {
    "id": "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4"
  }
}
  • The response body is the VC body.

Create verifiable presentation (VP)

Request: https://test-auth.protx.io/v2/did/create-vp****

{
    "holder": "did:ethr:0xa54545a4e45cf5a229438695c6bea23c5d1414c9",
    "verifier": "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4",
    "credentials": [
        {
            "credentialSubject": {
                "userId": "sus",
                "name": "ss",
                "phone": "019-3992-6444",
                "birthdate": "2022-10-19",
                "dRegNumber": "ss",
                "sub": "7005550002",
                "id": "did:ethr:0xa54545a4e45cf5a229438695c6bea23c5d1414c9"
            },
            "issuer": {
                "id": "did:ethr:0xa3bbf50a3c3a4180521325cb99ea301142b3634e"
            },
            "type": [
                "VerifiableCredential",
                "Profile"
            ],
            "@context": [
                "https://www.w3.org/2018/credentials/v1"
            ],
            "issuanceDate": "2022-10-19T10:42:13.000Z",
            "proof": {
                "type": "JwtProof2020",
                "jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiUHJvZmlsZSJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJ1c2VySWQiOiJzdXMiLCJuYW1lIjoic3MiLCJwaG9uZSI6IjAxOS0zOTkyLTY0NDQiLCJiaXJ0aGRhdGUiOiIyMDIyLTEwLTE5IiwiZFJlZ051bWJlciI6InNzIiwic3ViIjoiNzAwNTU1MDAwMiJ9fSwic3ViIjoiZGlkOmV0aHI6MHhhNTQ1NDVhNGU0NWNmNWEyMjk0Mzg2OTVjNmJlYTIzYzVkMTQxNGM5IiwibmJmIjoxNjY2MTc2MTMzLCJpc3MiOiJkaWQ6ZXRocjoweGEzYmJmNTBhM2MzYTQxODA1MjEzMjVjYjk5ZWEzMDExNDJiMzYzNGUifQ.LrTCG_SPXE-qpicQvTlaw666cmDpsZEILPpCAVRMBbjB-Yp-GMY0arqTxgc0rTRD3XlXV57JhCkZKYBZ261Dxg"
            }
        }
    ]
}
  • "holder" is your DID.

  • "verifier" is the verifier DID provided by this authentication system.

  • credentials contains a list of VCs.

Response:

{
  "issuanceDate": "2022-10-21T06:16:23.000Z",
  "verifier": [
    "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4"
  ],
  "holder": "did:ethr:0xa54545a4e45cf5a229438695c6bea23c5d1414c9",
  "proof": {
    "type": "JwtProof2020",
    "jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2cCI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVQcmVzZW50YXRpb24iLCJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIlByb2ZpbGUiXSwidmVyaWZpYWJsZUNyZWRlbnRpYWwiOlsiZXlKaGJHY2lPaUpGVXpJMU5rc2lMQ0owZVhBaU9pSktWMVFpZlEuZXlKMll5STZleUpBWTI5dWRHVjRkQ0k2V3lKb2RIUndjem92TDNkM2R5NTNNeTV2Y21jdk1qQXhPQzlqY21Wa1pXNTBhV0ZzY3k5Mk1TSmRMQ0owZVhCbElqcGJJbFpsY21sbWFXRmliR1ZEY21Wa1pXNTBhV0ZzSWl3aVVISnZabWxzWlNKZExDSmpjbVZrWlc1MGFXRnNVM1ZpYW1WamRDSTZleUoxYzJWeVNXUWlPaUp6ZFhNaUxDSnVZVzFsSWpvaWMzTWlMQ0p3YUc5dVpTSTZJakF4T1Mwek9Ua3lMVFkwTkRRaUxDSmlhWEowYUdSaGRHVWlPaUl5TURJeUxURXdMVEU1SWl3aVpGSmxaMDUxYldKbGNpSTZJbk56SWl3aWMzVmlJam9pTnpBd05UVTFNREF3TWlKOWZTd2ljM1ZpSWpvaVpHbGtPbVYwYUhJNk1IaGhOVFExTkRWaE5HVTBOV05tTldFeU1qazBNemcyT1RWak5tSmxZVEl6WXpWa01UUXhOR001SWl3aWJtSm1Jam94TmpZMk1UYzJNVE16TENKcGMzTWlPaUprYVdRNlpYUm9jam93ZUdFelltSm1OVEJoTTJNellUUXhPREExTWpFek1qVmpZams1WldFek1ERXhOREppTXpZek5HVWlmUS5MclRDR19TUFhFLXFwaWNRdlRsYXc2NjZjbURwc1pFSUxQcENBVlJNQmJqQi1ZcC1HTVkwYXJxVHhnYzByVFJEM1hsWFY1N0poQ2taS1lCWjI2MUR4ZyJdfSwibmJmIjoxNjY2MzMyOTgzLCJpc3MiOiJkaWQ6ZXRocjoweGE1NDU0NWE0ZTQ1Y2Y1YTIyOTQzODY5NWM2YmVhMjNjNWQxNDE0YzkiLCJhdWQiOlsiZGlkOmV0aHI6MHhkMjg0Y2RjOTY0YWY4YTAxZDgyZDBjYWE3ZGVlYmE4Mjc4NWI1NGY0Il19.AjFvyK-4yYH7PHMZT2c-ZsBiquX8ZPZARwmMHcYNtkup15CqCgq1GFcQOWEtvDfwkj8abJH4kH4ffCreWR1tWQ"
  },
  "type": [
    "VerifiablePresentation",
    "VerifiableCredential",
    "Profile"
  ],
  "@context": [
    "https://www.w3.org/2018/credentials/v1"
  ],
  "verifiableCredential": [
    {
      "credentialSubject": {
        "userId": "sus",
        "name": "ss",
        "phone": "019-3992-6444",
        "birthdate": "2022-10-19",
        "dRegNumber": "ss",
        "sub": "7005550002",
        "id": "did:ethr:0xa54545a4e45cf5a229438695c6bea23c5d1414c9"
      },
      "issuer": {
        "id": "did:ethr:0xa3bbf50a3c3a4180521325cb99ea301142b3634e"
      },
      "type": [
        "VerifiableCredential",
        "Profile"
      ],
      "@context": [
        "https://www.w3.org/2018/credentials/v1"
      ],
      "issuanceDate": "2022-10-19T10:42:13.000Z",
      "proof": {
        "type": "JwtProof2020",
        "jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiUHJvZmlsZSJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJ1c2VySWQiOiJzdXMiLCJuYW1lIjoic3MiLCJwaG9uZSI6IjAxOS0zOTkyLTY0NDQiLCJiaXJ0aGRhdGUiOiIyMDIyLTEwLTE5IiwiZFJlZ051bWJlciI6InNzIiwic3ViIjoiNzAwNTU1MDAwMiJ9fSwic3ViIjoiZGlkOmV0aHI6MHhhNTQ1NDVhNGU0NWNmNWEyMjk0Mzg2OTVjNmJlYTIzYzVkMTQxNGM5IiwibmJmIjoxNjY2MTc2MTMzLCJpc3MiOiJkaWQ6ZXRocjoweGEzYmJmNTBhM2MzYTQxODA1MjEzMjVjYjk5ZWEzMDExNDJiMzYzNGUifQ.LrTCG_SPXE-qpicQvTlaw666cmDpsZEILPpCAVRMBbjB-Yp-GMY0arqTxgc0rTRD3XlXV57JhCkZKYBZ261Dxg"
      }
    }
  ]
}
  • The response body is the VP body.

List issuers and verifiers

Obtain the list of issuers and verifiers allowed by this authentication system. These APIs use the GET method.

Request: https://test-auth.protx.io/v2/did/issuers****

Response:

[
  {
    "alias": "prot",
    "did": "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4"
  },
  {
    "alias": "medi",
    "did": "did:ethr:0xa3bbf50a3c3a4180521325cb99ea301142b3634e"
  }
]

Request: https://test-auth.protx.io/v2/did/verifiers****

Response:

[
  {
    "alias": "prot",
    "did": "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4"
  },
  {
    "alias": "medi",
    "did": "did:ethr:0xa3bbf50a3c3a4180521325cb99ea301142b3634e"
  }
]

Login with verifiable presentation (VP)

Request: https://test-auth.protx.io/v2/auth/auth-user-with-vp****

{
    "requestId": "https://test-admin.protx.io/?requestId=1234124_1242",
    "vp": {
        "verifiableCredential": [
            {
                "credentialSubject": {
                    "name": "asd",
                    "phone": "432-4324",
                    "sub": "01022223333",
                    "id": "did:ethr:0xb80a41cd53c3a42faa5a5f58e61909e50df811e0"
                },
                "issuer": {
                    "id": "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4"
                },
                "type": [
                    "VerifiableCredential",
                    "Profile"
                ],
                "@context": [
                    "https://www.w3.org/2018/credentials/v1"
                ],
                "issuanceDate": "2022-10-18T09:14:22.000Z",
                "proof": {
                    "type": "JwtProof2020",
                    "jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiUHJvZmlsZSJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJuYW1lIjoiYXNkIiwicGhvbmUiOiI0MzItNDMyNCIsInN1YiI6IjAxMDIyMjIzMzMzIn19LCJzdWIiOiJkaWQ6ZXRocjoweGI4MGE0MWNkNTNjM2E0MmZhYTVhNWY1OGU2MTkwOWU1MGRmODExZTAiLCJuYmYiOjE2NjYwODQ0NjIsImlzcyI6ImRpZDpldGhyOjB4ZDI4NGNkYzk2NGFmOGEwMWQ4MmQwY2FhN2RlZWJhODI3ODViNTRmNCJ9.PqUOVrxFI8Bmt2UKjJ2oF6oFNkV_0s9xzJczPwkDf8_fueJdBoK3OuOKnWPfS-wgSDTDMpyNlf_m27DoxvA1pA"
                }
            }
        ],
        "holder": "did:ethr:0xb80a41cd53c3a42faa5a5f58e61909e50df811e0",
        "verifier": [
            "did:ethr:0xd284cdc964af8a01d82d0caa7deeba82785b54f4"
        ],
        "type": [
            "VerifiablePresentation",
            "VerifiableCredential",
            "Profile"
        ],
        "@context": [
            "https://www.w3.org/2018/credentials/v1"
        ],
        "issuanceDate": "2022-10-18T09:14:26.000Z",
        "proof": {
            "type": "JwtProof2020",
            "jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2cCI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVQcmVzZW50YXRpb24iLCJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIlByb2ZpbGUiXSwidmVyaWZpYWJsZUNyZWRlbnRpYWwiOlsiZXlKaGJHY2lPaUpGVXpJMU5rc2lMQ0owZVhBaU9pSktWMVFpZlEuZXlKMll5STZleUpBWTI5dWRHVjRkQ0k2V3lKb2RIUndjem92TDNkM2R5NTNNeTV2Y21jdk1qQXhPQzlqY21Wa1pXNTBhV0ZzY3k5Mk1TSmRMQ0owZVhCbElqcGJJbFpsY21sbWFXRmliR1ZEY21Wa1pXNTBhV0ZzSWl3aVVISnZabWxzWlNKZExDSmpjbVZrWlc1MGFXRnNVM1ZpYW1WamRDSTZleUp1WVcxbElqb2lZWE5rSWl3aWNHaHZibVVpT2lJME16SXRORE15TkNJc0luTjFZaUk2SWpBeE1ESXlNakl6TXpNekluMTlMQ0p6ZFdJaU9pSmthV1E2WlhSb2Nqb3dlR0k0TUdFME1XTmtOVE5qTTJFME1tWmhZVFZoTldZMU9HVTJNVGt3T1dVMU1HUm1PREV4WlRBaUxDSnVZbVlpT2pFMk5qWXdPRFEwTmpJc0ltbHpjeUk2SW1ScFpEcGxkR2h5T2pCNFpESTROR05rWXprMk5HRm1PR0V3TVdRNE1tUXdZMkZoTjJSbFpXSmhPREkzT0RWaU5UUm1OQ0o5LlBxVU9WcnhGSThCbXQyVUtqSjJvRjZvRk5rVl8wczl4ekpjelB3a0RmOF9mdWVKZEJvSzNPdU9LbldQZlMtd2dTRFRETXB5TmxmX20yN0RveHZBMXBBIl19LCJuYmYiOjE2NjYwODQ0NjYsImlzcyI6ImRpZDpldGhyOjB4YjgwYTQxY2Q1M2MzYTQyZmFhNWE1ZjU4ZTYxOTA5ZTUwZGY4MTFlMCIsImF1ZCI6WyJkaWQ6ZXRocjoweGQyODRjZGM5NjRhZjhhMDFkODJkMGNhYTdkZWViYTgyNzg1YjU0ZjQiXX0.fLwCJfdJdtZDtAm8jipG7EJ_Qyrv-03XmwGWnWOhyGg_XNFKX4K271HB2zkTIUbcbU8VavjlWMNlkuwEiV8Kog"
        }
    }
}
  • Put the VP body in "vp".

  • In case of the application's own login, "requestId" is not needed. "requestId" is required for web site login. When the web site shows the QR code through the browser, the user application reads this value, puts it in the "requetId", and calls this API to log in to the web site.

Response:

{
  "token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIwMTAyMjIyMzMzMyIsInJvbGUiOiJST0xFX1VTRVIiLCJleHAiOjE2Njg3Nzg5NzAsInVzZXIiOiI0NzAwNjBFRkNCRUMwMDJDIiwiaWF0IjoxNjY2MTg2OTcwfQ.h9bMc-mmswRcI8vLfl1E-a65hcIvqdKikcj_50ZOI8k",
  "userId": "01022223333",
  "name": "test1",
  "telNo": "01022223333",
  "email": ""
}

Last updated