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
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
Go to the Hello KRNL Template on Atlas IDE
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.
III. Registering Your Smart Contract
Go to the smart contract registration page
Connect your MetaMask Wallet to the platform
Click on "Register"

Fill the required values:
Network -> Sepolia
Smart Contract Address -> Address of the deployed Main contract
Choose Kernel -> Type 337 and select kernel ID 337
Token Authority Address -> Address of the deployed TokenAuthority contract

Click on "Activate" and confirm the transaction to register your smart contract
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
Go to the dApp registration page
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
Go to the KRNL Sandbox
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

Now click on the transaction, once it's confirmed, and view the transaction on a blockchain explorer like Etherscan
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
Last updated
Was this helpful?