CLI
Goal: To complete the integration of KRNL into your application and to be able to execute verifiable workflows within your environment.
Read time - 30 minutes
This guide contains the instructions for deploying relevant components and using the KRNL SDK and KRNL CLI. For this demo we will use a mock business application where you can submit data, analyze it using a combination of external APIs, run this dataset through an AI model, and get a final verified result to use in your application and the best part is we will do all of this in a single atomic transaction with cryptographic proof. This demo will help you understand the steps to follow to integrate the KRNL Protocol into your application and create a KRNL-powered workflow.
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 (You can download and install using this link)
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

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:
Follow this guide to export MetaMask private key
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:

You have to deploy your own target contract where your EOA will be used as the master key for signature verification, you will learn about this later in the docs
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
We will learn more about workflow DSL later in Workflows. For now make sure to add the exact key pair as a part of creating attestor image
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
Your app will be available at http://localhost:5173/
5. Run your KRNL workflow
We are running this workflow from your user's point of view
5.1 Connect your wallet

5.2 Fund the embedded wallet with Sepolia ETH token

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

This embedded wallet is completely independent of your external wallet to make sure your users' personal wallets are safe when delegating execution to our delegated account.
5.4 Run the workflow DSL

The time taken for the execution depends on the latency of the external services being used in the workflow.
5.5 Verify the execution in your target contract

The event signifies that the function was called with the KRNL response, the response signature was verified by the modifier and the response was decoded for the application.
These steps signify the happy path to deploying your first KRNL-powered application which lets you use functions across multiple environments as well as external APIs, letting you build applications without being limited by existing system 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