KRNL Platform Guidebook
KRNL Platformkrnl.xyz
  • Introduction
    • Introduction
    • How Does kOS Work?
  • Setup
    • Getting Started with KRNL
    • Quick Start (CLI)
    • Quick Start (Online IDE)
      • Quick Start (Remix IDE)
      • Quick Start (Atlas IDE)
    • create-krnl-app
    • Platform Registration
  • Kernel
    • What are Kernels?
    • Kernel Registration
      • Kernel Registration (on-chain)
      • Kernel Registration (off-chain)
    • Supported OpenAPI (Off-chain Kernel)
    • Staking
  • Smart Contract
    • Steps for Smart Contract Developers
    • Choosing Kernel(s)
    • Token Authority
      • What is a Token Authority?
      • How to Build a Token Authority?
      • Generic Token Authority
      • How to Deploy a Token Authority on Oasis?
    • Decoding Kernel Responses in Solidity
    • How to Integrate Your Smart Contract with kOS?
    • Smart Contract Registration
  • DApp
    • dApp Registration
    • KRNL SDK Installation
    • Usage
    • KRNL Node RPC
  • Miscellaneous
    • Overview
    • What is the KRNL Platform?
    • What are You Trying to BUIDL?
    • Smart Contract Fundamentals
      • Why Do I Have to Register a Smart Contract?
      • How to Deploy a Smart Contract?
    • Recommended Kernels List
  • Helpful Resources
    • New to Web3?
    • Dictionary
    • Testnet Faucets
    • How to Get Etherscan API Key?
  • Litepaper
    • Litepaper
      • Overview
      • Problem Statement
      • Current State Does Not Solve the Problem
      • Introducing Kernels
      • Ecosystem of Kernels
      • The KRNL Operating System (kOS)
      • Decentralization and Security Considerations
      • Use Cases for KRNL
  • Appendices
    • FAQ
    • Bounty Program
    • Social Medias
    • Thank You
  • Workshop
    • KRNL Workshop
Powered by GitBook
On this page
  • [kernel ID: 337] Prohibited List
  • [kernel ID: 340] Trusted List
  • [kernel ID: 341] Mock Oracle
  • [kernel ID: 347] Day and Time
  • [kernel ID: 875] Mock Oracle

Was this helpful?

  1. Miscellaneous

Recommended Kernels Detailed

Last updated 3 months ago

Was this helpful?

This page is an extension of the Recommended Kernels List page.

It contains explanations for some kernels and also the potential of utilizing those kernels into smart contracts.


[kernel ID: 337] Prohibited List

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

contract ProhibitedListKernel {

    mapping(address => bool) public walletAddressList;

    function addProhibitedList() public {
        require(!walletAddressList[msg.sender], "You are already on this Prohibited List!");
        walletAddressList[msg.sender] = true;
    }

    function areYouOnProhibitedList(address _toCheck) public view returns (uint256){
        
        if (walletAddressList[_toCheck] == true) {
            return 0;
        } else {
            return 100;
        }
    }

}

Prohibited List kernel is an on-chain function for smart contracts that is deployed on Base Sepolia.

It illustrates that if this kernel executes before calling to smart contract, it can help protect malicious wallet addresses from calling your smart contract.


[kernel ID: 340] Trusted List

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

contract TrustedListKernel {

    mapping(address => bool) public walletAddressList;

    function addTrustedList(address _toAdd) public {
        require(!walletAddressList[_toAdd], "You are already on this Trusted List!");
        walletAddressList[_toAdd] = true;
    }

    function areYouOnTrustedList(address _toCheck) public view returns (bool){
        
        if (walletAddressList[_toCheck] == true) {
            return true;
        } else {
            return false;
        }
    }

}

Trusted List kernel is an on-chain function on smart contract that is deployed on Base Sepolia.

If we use this kernel through KRNL Protocol, only allowed users would be able to use the smart contract.

Instead of having to manage the list of allowed users through the primary smart contract, using this category of kernel could improve the modularity of Web3 transactions.


[kernel ID: 341] Mock Oracle

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

contract MockOracle {

    function getRandomExchangeRate(string memory input) public view returns (uint256) {
        
        // high and low of BTC to USD in 2024
        uint256 BTCUSDmin = 40000;
        uint256 BTCUSDmax = 100000;

        // high and low of ETH to USD in 2024
        uint256 ETHUSDmin = 2200;
        uint256 ETHUSDmax = 4000;


        uint256 BTCUSDrandom = (block.timestamp + block.number) % (BTCUSDmax - BTCUSDmin + 1);
        uint256 BTCUSDresult = BTCUSDrandom + BTCUSDmin;

        uint256 ETHUSDrandom = (block.timestamp + block.number) % (ETHUSDmax - ETHUSDmin + 1);
        uint256 ETHUSDresult = ETHUSDrandom + ETHUSDmin;

        if (keccak256(abi.encodePacked(input)) == keccak256(abi.encodePacked("BTC/USD"))) {
            return BTCUSDresult;
        } else if (keccak256(abi.encodePacked(input)) == keccak256(abi.encodePacked("ETH/USD"))) {
            return ETHUSDresult;
        } else {
            return 0;
        }

    }
}

Mock Oracle kernel is an on-chain function for smart contracts that is deployed on Arbitrum Sepolia.

It shows that kernels do not have to be only protection for the smart contract. Utilizing KRNL Protocol into the smart contract expands the potential of fetching data from other sources.

The fetched value from this kernel can be shown after finishing the transaction through an event.


[kernel ID: 347] Day and Time

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/utils/Strings.sol";

contract TimeKernel {

    struct HourAndMinute {
        uint256 hourInNum;
        uint256 minuteinNum;
    }

    function getDayOfWeek() public view returns (string memory) {
        
        string[7] memory dayArray = [
                                    "Sunday",
                                    "Monday",
                                    "Tuesday",
                                    "Wednesday",
                                    "Thursday",
                                    "Friday",
                                    "Saturday"
                                    ];
        
        uint256 dayIndex = (block.timestamp / 86400 + 4) % 7; // 86400 seconds in a day
        
        return dayArray[dayIndex];
    }

    function getTimeFromBlock() public view returns (HourAndMinute memory) {

        uint256 hourFromBlock = (block.timestamp / 3600) % 24;

        uint256 minuteFromBlock = (block.timestamp / 60) % 60;

        HourAndMinute memory returnResults = HourAndMinute(hourFromBlock, minuteFromBlock);

        return returnResults;
    }

    function toString(HourAndMinute memory _input, string memory _inputDay) public view returns (string memory) {
        string memory returnText = string(
                                        abi.encodePacked(
                                            _inputDay,
                                            " at ",
                                            Strings.toString(_input.hourInNum),
                                            ":",
                                            Strings.toString(_input.minuteinNum),
                                            " (GMT+0)"));
        return returnText;
    }

    function getDayAndTime() public view returns (string memory) {
        return toString(getTimeFromBlock(), getDayOfWeek());
    }
}

Day and Time kernel is an on-chain function for smart contracts that is deployed on Optimism Sepolia.

In this case, the response from Day and Time kernel is only the day of week and current time (in GMT+0).

Similarly to Mock Oracle kernel, this kernel shows that the fetched data from other sources can be many types of data.

This category of kernel can include on-chain kernels like this one, as well as off-chain (Web2 API) kernels too.

Other potential examples similar to this kernel include: current temperature in your city, recent sports results, and more.


[kernel ID: 875] Mock Oracle

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

contract MockEthPriceOracle {

    function getEthToUsd() public view returns (uint256) {

        // high and low of ETH to USD in 2024
        uint256 ETHUSDmin = 2200;
        uint256 ETHUSDmax = 4000;

        uint256 ETHUSDrandom = (block.timestamp + block.number) % (ETHUSDmax - ETHUSDmin + 1);
        uint256 ETHUSDresult = ETHUSDrandom + ETHUSDmin;

        return ETHUSDresult;
    }
}

Mock Oracle kernel is an on-chain function for smart contracts that is deployed on Arbitrum Sepolia.

It shows that kernels do not have to be only protection for the smart contract. Utilizing KRNL Protocol into the smart contract expands the potential of fetching data from other sources.

The fetched value from this kernel can be shown after finishing the transaction through an event.

https://sepolia.basescan.org/address/0xf11D98eFA214920Af9a3358bab0adb0F2B0FD29a#codesepolia.basescan.org
https://sepolia.basescan.org/address/0x6b751f2b74aba52404529c48d3b59805d38ac43b#codesepolia.basescan.org
https://sepolia.arbiscan.io/address/0x0E709e842A7126FFf74F22041Ff10A38e8348e76#codesepolia.arbiscan.io
https://sepolia-optimism.etherscan.io/address/0x18e3dd5289a59487196cde781fca01df6c8c9aaf#codesepolia-optimism.etherscan.io
https://sepolia.arbiscan.io/address/0xe2f6889061bf9cf100271896c3cd3edcf7ff96bf#codesepolia.arbiscan.io