Usage
Prerequisites
Guide for registering your dApp here.
It is suggested to try completing 10-minutes Tutorial before reading this page, since the code example will refer to kernel 337 (example kernel of 10-minutes Tutorial).
It is recommended to explore the documentations from the kernel(s) that you are going to select.
Every kernel is different when it comes to response data types, authentication methods/keys, etc.
executeKernels(...)
There are 4 parameters which are required for using this function from the KRNL SDK.
entryId - obtain after dApp registration
accessToken - obtain after dApp registration
kernelRequestData - parameter(s) that will be sent to predefined kernel(s)
functionParams - parameter that will be sent to registered smart contract
The below code snipped is the example of how to use executeKernels(...)
function, as well as how to utilize the response from with the transaction.
This snipped is made from Next.js (JavaScript). Feel free to try it with other environment such as Next.js (TypeScript), React, or else.
Off-chain Kernel (GET method) Example
getKernelsCost(...)
This function is not essential for using the KRNL protocol. Implementing getKernelsCost
on your dApp can show the cost of utilized kernels to the user.
entryID is the parameter which you should already have at this point. Assuming that the entryID for this case is 12345 as in the example below.
Last updated