CLI
Goal: To complete the integration of kOS into your smart contract and to be able to call transactions within a dApp.
Read time - 30 minutes
This guide contains the instructions for deploying relevant smart contracts and using the KRNL SDK and KRNL CLI . For this demo we will use a mock realestate dApp where you can list your property, analyze the property score using a bunch of external APIs, run this dataset through OpenAI GPT API and get a final score to use in the contract and the best part is we will do all of this in a atomic transaction. This demo will help you understand the steps to follow to integration KRNL protocol to your smart contract and create a KRNL integrated dApp
Preparations
Install Docker
Go to https://www.docker.com/get-started/ and install Docker Desktop
Make sure you sign in/create an account for docker desktop
Etherscan (for verifying smart contracts on Sepolia network) - Find the API key here
Sepolia testnet - "Add a custom network" on your MetaMask wallet
Funds - make sure you have a SepoliaETH by claiming them from faucets here.
Sepolia token ≈ 0.1 SepoliaETH
Privy App ID and Secret
Go to dashboard.privy.io
Create an app
Copy the App ID and secret
MetaMask - You can download and install using this link

Pimlico API Key
Go to https://dashboard.pimlico.io/sign-in and create an account/sign in with your existing account
Then navigate to https://dashboard.pimlico.io/apikeys and create your api key
Keep this API key for later use
Deploy the Target Contract
1. Install the KRNL CLI
Go to your terminal and run this command:
2. Clone the repo
Go to your terminal and run this command:
3. Go to contract folder
Run this command:
Create the .env file
1.1 Copy .env.example to .env
1.2 Fill the .env file with these values:
Deploy the contract
1.1 Run the following command to install the forge dependencies:
1.2 Run the following command to deploy the contract:
1.3 After the deployment you get screen like this:

Setup the Attestor Image
Attestor is a component which will attest and also resolve the secrets in your DSL workflow (don't worry we will learn about all of this in the core concepts)
1. Run the Attestor
2. Follow the onscreen instruction
2.1 Enter your project name:

2.2 Enter Docker registry, it should docker.io

2.3 Enter your docker username

The script pushes an attestor image to your docker hub so make sure to sign in and ensure that your docker desktop is running in the background while this script is being executed
2.4 Enter your private key

2.5 Create a encryption secret which is a password to the safe carrying your private key to make your private key is handled safely. Press enter to auto generate

This is the same private key which you have derived from your MetaMask wallet
2.6 Pass the secrets to resolve in the DSL workflow during execution. For our real estate workflow example, we need:
rpcSepoliaURL=<ethereum_sepolia_rpc>
pimlico-apikey=<api_key_of_your_pimlico_account>
OPENAI_API_KEY=mock-api (We are using a mock api in our DSL for the sake of the demo)

Make sure to replace '<>' with actual values
2.7 Wait for few seconds and you will see a success screen with your attestor image

Setup the dApp
1. Go to frontend folder from the contract folder
2. Create the .env file
2.1 Copy .env.example to .env
2.2 Fill the .env file with these values:
3. Install the dependencies
4. Run the application
5. Run your KRNL workflow
5.1 Connect your wallet

5.2 Fund the embedded wallet with Sepolia ETH token

This wallet is different from your EOA wallet and this is created automatically as soon as you sign in
5.3 Delegate execution to KRNL smart contract account

5.4 Run the workflow DSL

5.5 Verify the execution in your target contract

These steps signifies the happy path to deploying using first KRNL integrated application which let's you use functions from our EVM contracts across multiple chains as well using external API letting you build dApps like apps without being limited by the existing smart contracts design
What's next?
Congrats on completing your first hands-on tutorial using KRNL now it's time to learn the Core Concepts to understand all the concepts and flows in detail.
Last updated

