Kernel Registration (off-chain)

In this tutorial, we will have a mock API , which can use either the GET or POST method. This API works by taking the input parameter of wallet address, and returning the result of wallet score.

This page provides an example of both the GET method and the POST method.

For the GET method, the input parameter of a wallet address has to be sent within the API path.

Similarly, for the POST method, the input parameter of a wallet address has to be sent within the "Request" body. The "Response" of the API will return the wallet score.

In this tutorial, we will use a mock endpoint called <web2-off-chain.com>.

As in the image above, some additional information is required.


API Schema Examples

GET method

You must provide the OpenAPI schema which will be called through the protocols.

Let's assume that the "Request" and "Response" of your API are in the below example code blocks:

The mock endpoint is <web2-off-chain.com/wallet-check-get-{}>.

For the GET method, the wallet address that needs to be checked is sent within the endpoint.

That will give us the OpenAPI schema, as in the below code block.

{
  "openapi": "3.0.3",
  "info": {
    "title": "Wallet Score Check GET",
    "version": "1.0.0",
    "description": "API for checking the score and status of a wallet address."
  },
  "servers": [
    {
      "url": "https://web2-off-chain.com"
    }
  ],
  "paths": {
    "/wallet-check-get-{wallet_address}": {
      "get": {
        "summary": "Check the score of a wallet address",
        "parameters": [
          {
            "name": "wallet_address",
            "in": "path",
            "required": true,
            "description": "The wallet address to check.",
            "schema": {
              "type": "string",
              "example": "0x1234567890"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallet_address": {
                      "type": "string",
                      "example": "0x1234567890"
                    },
                    "score": {
                      "type": "integer",
                      "example": 57
                    },
                    "status": {
                      "type": "string",
                      "example": "pass"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Wallet not found"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "WalletCheckResponse": {
        "type": "object",
        "properties": {
          "wallet_address": {
            "type": "string"
          },
          "score": {
            "type": "integer"
          },
          "status": {
            "type": "string"
          }
        }
      }
    }
  }
}

POST method

When using the POST method, you must provide the OpenAPI schema, which will be called through the protocols.

Let's assume that the "Request" and "Response" of your API are in the below example code blocks:

The endpoint is <web2-off-chain.com/wallet-check>.

Request

{
    "id": 6789,
    "name": "Alice",
    "age": 35,
    "wallet_address": "0x1234567890"
}

Response

{
    "wallet_address": "0x1234567890",
    "score": 57,
    "status": "pass"
}

The example of OpenAPI for POST method will be as in the code block below.

{
  "openapi": "3.0.3",
  "info": {
    "title": "Wallet Score Check",
    "version": "1.0.0",
    "description": "API for checking the score and status of a wallet address."
  },
  "servers": [
    {
      "url": "https://web2-off-chain.com"
    }
  ],
  "paths": {
    "/wallet-check": {
      "post": {
        "summary": "Check the score of a wallet address",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer",
                    "default": 1234,
                    "example": 6789
                  },
                  "name": {
                    "type": "string",
                    "example": "Alice"
                  },
                  "age": {
                    "type": "integer",
                    "example": 35
                  },
                  "wallet_address": {
                    "type": "string",
                    "description": "User define"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "wallet_address": {
                      "type": "string",
                      "example": "0x1234567890"
                    },
                    "score": {
                      "type": "integer",
                      "example": 57
                    },
                    "status": {
                      "type": "string",
                      "example": "pass"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "404": {
            "description": "Wallet not found"
          },
          "500": {
            "description": "Internal server error"
          }
        }
      }
    }
  }
}

After clicking Upload, a CID will be generated for your specific off-chain API.


After filling the required information, "Fee Per Query" will be the crucial field in this process. It is the part where you, as service providers, can define how much users have to pay when they execute your services. The picture below shows the Fee Per Query and Staking sections. "Additional Information" contains optional fields where you can fill the name, logo, and more.

After pressing the "Activate" button at the bottom of the page, a review window will pop up for you to revise and confirm, as shown in the picture below.

Once you have submitted the transaction, a "Transaction Complete" window will be displayed.

Congratulations! You have successfully registered your service as one of our kernels!

Last updated

Was this helpful?