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
    • Speed's Workshop
Powered by GitBook
On this page
  • I. Preparations
  • II. Compiling and Deploying the Contract
  • Step 1: Deploying TokenAuthority Contract
  • Step 2: Fetching the TA Public Key
  • Step 3: Deploying Main Contract
  • III. Registering Your Smart Contract
  • IV. Registering your dApp
  • V. Test Your KRNL Implementation Using the Sandbox
  • Frequently Asked Questions

Was this helpful?

  1. Setup
  2. Quick Start (Online IDE)

Quick Start (Atlas IDE)

Goal: To complete the integration of kOS into your smart contract and to be able to call transactions within a dApp.

PreviousQuick Start (Remix IDE)Nextcreate-krnl-app

Last updated 8 days ago

Was this helpful?

Read time - 10 minutes

This guide contains the instructions for deploying relevant smart contracts and using the KRNL SDK through KRNL Sandbox.

Choosing a kernel is predefined for simplicity and ease of understanding throughout this easy-to-follow guide.


I. Preparations

MetaMask

MetaMask is a popular wallet that works as a browser extension.

Here's a simple step-by-step installation guide.

Step 1: Open Your Web Browser

MetaMask works with Chrome, Firefox, Brave, and more.

Step 2: Find the MetaMask Extension

Go to the official or search for "MetaMask" in your browser's extension store/web store.

Step 3: Add MetaMask to Your Browser

Click the "Download" or "Add to Browser" button. A confirmation pop-up will appear - click "Add Extension."

Step 4: Set Up Your Wallet

After installation, MetaMask will open automatically. Click "Get Started."

Step 5: Create a New Wallet

Select "Create a Wallet" if you're new to MetaMask.

Step 6: Create a Password

Create a strong password for your MetaMask account.

This is different from your seed phrase and is used to unlock the app on your device.

Step 7: Secret Recovery Phrase

  • MetaMask will show you a 12-word recovery phrase (also called a seed phrase)

  • Write these phrases down on paper and store them somewhere very secure

  • Never share these phrases with anyone or store them digitally

  • You'll need to confirm the phrase on the next screen

Step 8: Confirm Your Secret Recovery Phrase

MetaMask will ask you to confirm your secret seed phrase by selecting words in the correct order.

Step 9: Congratulations!

You have successfully set up MetaMask. Your Ethereum wallet address and balance (which will be zero to start with) will be shown.

Etherscan API Key

Oasis Sapphire Testnet

Here's a step-by-step guide to help you add Oasis Sapphire Testnet to your MetaMask.

Make sure you choose either of these two methods:

Method 1: Using Chainlist (Easiest)

  1. Go to Chainlist.org

    • Open your web browser and go to

  1. Connect your Wallet

    • Click the "Connect Wallet" button in the top-right corner

    • Approve the connection request in your MetaMask pop-up

  1. Add Oasis Sapphire Network

    • Click the "Add to MetaMask" button next to it

    • A MetaMask pop-up will appear with the network details

    • Click "Approve" to add the network

  1. Switch to Oasis Sapphire

    • MetaMask will ask if you want to switch to the Oasis Sapphire network

    • Click "Switch network"

    • You're now connected to Oasis Sapphire!


Method 2: Adding Manually

  1. Open MetaMask Extension

    • Click on the MetaMask icon in your browser

    • Ensure you're logged in

  2. Open Network Settings

    • Click on the network dropdown at the top

    • Scroll down and click "Add network"

  3. Add a Network Manually

    • Click "Add a network manually" at the bottom of the page

  4. Enter Oasis Sapphire Network Details

    Network name:
        Oasis Sapphire Testnet
    RPC:
        https://testnet.sapphire.oasis.io
    Chain ID:
        23295
    Currency symbol:
        TEST
    Block explorer URL:
        https://explorer.oasis.io/testnet/sapphire/
  5. Save the Network

    • Click "Save"

    • MetaMask will automatically connect to the Oasis Sapphire network

Funds

make sure you have a SepoliaETH and Oasis TEST token (Oasis Sapphire testnet) balance, by claiming them from .

  • Sepolia token ≈ 0.1 SepoliaETH

  • Oasis Sapphire testnet token ≈ 0.6 TEST


II. Compiling and Deploying the Contract

To compile and deploy the KRNL smart contracts, we will use Atlas IDE.

Atlas is a browser-based IDE with a handy AI assistant to help you craft, test, and launch smart contracts—all from your browser.

Step 1: Deploying TokenAuthority Contract

  • Click on Clone Project

  • Use "Hello KRNL" as a suggested project name

  • Next, a MetaMask pop-up will appear, prompting you to connect your newly created wallet to the IDE

  • Now, double-check the network panel on the right of your screen for the following information:

    • Network: Oasis Sapphire Testnet ✅

    • Wallet: Connected ✅

    • Contract: TokenAuthority.sol ✅

  • Next, click on the "Deploy" button. This will prompt you to enter the address of the initial owner. To keep it simple, we will use the address of our MetaMask wallet as the initial owner.

  • Once you submit the wallet address, MetaMask will prompt you to confirm the transaction / This will deploy the TokenAuthority contract for you on the Oasis Sapphire testnet.

  • Voila! We have deployed our first contract and if you check the same panel on the right, it should have the option to copy your ABI and your smart contract.

Step 2: Fetching the TA Public Key

  • Copy the Token Authority Public Key from the right panel under the "getSigningKeypairPublicKey" section

  • Keep a note of this key as we will need it for deploying our next contract.

Note: Make sure to copy the second key in the list.

Step 3: Deploying Main Contract

  • On the left panel, select Sample.sol

  • Next, open your MetaMask extension and change the network to Sepolia

  • Again, double check the right panel to make sure of the following:

    • Network: Ethereum Sepolia Testnet ✅

    • Wallet: Connected ✅

    • Contract: Sample.sol ✅

  • Click on "Deploy", which will prompt you to enter _tokenAuthorityPublicKey which is the TA public key that we have copied in Step 2: Fetching the TA Public Key. Then, click deploy or press enter.

  • Finally, confirm the transaction when prompted. You have now deployed your last and final contract of this tutorial.

We have successfully deployed both our contracts. At this stage, make sure to save your Token Authority smart contract address and the smart contract address. We need both of them during registration process on the KRNL Platform.

Where to find the addresses?

III. Registering Your Smart Contract

  1. Connect your MetaMask Wallet to the platform

  2. Click on "Register"

  1. Fill the required values:

    1. Network -> Sepolia

    2. Smart Contract Address -> Address of the deployed Main contract

    3. Choose Kernel -> Type 337 and select kernel ID 337

    4. Token Authority Address -> Address of the deployed TokenAuthority contract

  1. Click on "Activate" and confirm the transaction to register your smart contract

  2. Wait until the transaction has finished

5. Now, go back to the smart contract page, click on the registered contract, and copy the contract ID

These steps ensure that our contract can access the kernel. The next step will make sure that any external entity can use the kernel via the smart contract. In this case, you have to register your smart contract as a dApp to access the kernel via your smart contract


IV. Registering your dApp

  1. Click "Register"

3. Fill in the Smart Contract ID that we copied in the last step

4. Click "Activate" and wait until the transaction has finished

5. Go to your registered dApp page and copy both "Entry ID" and "Access Token"


V. Test Your KRNL Implementation Using the Sandbox

  1. Connect your wallet and select the template "10-minutes Tutorial"

3. Fill in the required values from "smart contract deployment" and the KRNL platform

  • Smart Contract Address -> The address of your main contract

  • EntryID -> the Entry ID that we copied when registering the smart contract

  • Access Token -> the Access Token that we copied when registering the smart contract

4. The rest will be auto-filled, so now click "Execute Kernels"

5. If the execution is successful, you will see an encoded json output.

The parameter(s) has to be the same as in "Step 2: Fill Your Parameters".

If you are trying to fill different values on "Step 3: Submit Your Transaction", it means that you are trying to tamper with the transaction after already obtaining the response(s) from the kernel(s).

6. Now fill "SandboxTesting" as the string parameter to call the protectedFunction() and decode the output from the kernel.

7. Click "Submit Transaction" and wait for it to complete. You can also check your wallet to see if the transaction is successful or not

  1. Now click on the transaction, once it's confirmed, and view the transaction on a blockchain explorer like Etherscan

  2. Check the logs to see the decoded response from the kernel, under data

Congratulations! You have successfully implemented and tested a kernel in your smart contract.


Frequently Asked Questions

Check your connection error in Atlas IDE

This error occurs when you are inactive for a long period of time. To resolve this error, just refresh your page. This will trigger the IDE to establish the connection again.

"Sepolia" not found in MetaMask

This is a very common error and to resolve this make sure you have enabled the "Show test networks" option at the bottom of the network selection list.

We are using for this tutorial, which will return a score for the input address

Go to the on Atlas IDE

Go to the

Go to the

Go to the

kernel ID 337
Hello KRNL Template
smart contract registration page
dApp registration page
KRNL Sandbox
MetaMask website
How to get Etherscan API Key
Chainlist
faucets here