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.

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 MetaMask website 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

  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 faucets here.

  • 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.

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

Step 1: Deploying TokenAuthority Contract

  • 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.

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. Go to the KRNL Sandbox

  2. 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.

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.

Last updated

Was this helpful?