# How Does the KRNL Protocol Work?

#### This page is dedicated to illustrating how the KRNL Protocol works when a dApp submits a transaction to a smart contract, and how smart contracts receive responses from kernels. This is the high level architecture:

#### Step 1 — User interacts with dApp

The user initiates an action (e.g., rebalance, verify, fetch data) through the dApp frontend, which is integrated with KRNL SDK.

<figure><img src="/files/8U3vIBdTq8Qy9TNcmyhc" alt=""><figcaption></figcaption></figure>

#### Step 2 — User Account (EOA) Authorizes a smart contract account

The user’s Externally Owned Account (EOA) delegates execution rights to their SCA via EIP-7702, enabling account abstraction flows.

<figure><img src="/files/WKeCheQbdJcsXBiUmta0" alt=""><figcaption></figcaption></figure>

#### Step 3 — dApp uses KRNL SDK (fetch metadata)

The dApp backend uses the KRNL SDK to retrieve workflow definitions and registry metadata, ensuring the correct kernel set and logic are loaded.

<figure><img src="/files/ghxBxVi5l6PM9rEb4zM7" alt=""><figcaption></figcaption></figure>

#### Step 4 — SDK sends JSON-RPC request to KRNL Node

The execution request (workflow DSL + parameters) is transmitted to the KRNL-Node over JSON-RPC for orchestration.

<figure><img src="/files/GkRCHgz02iCtESYZk3E8" alt=""><figcaption></figcaption></figure>

#### Step 5 — Workflow Engine loads the workflow

KRNL-Node parses the workflow DAG, allocates resources, and prepares execution in isolated gVisor sandboxes.

<figure><img src="/files/HZ2YxkasnAw8YS1AYFxW" alt=""><figcaption></figcaption></figure>

#### Step 6 — Executor runs steps (sandboxed) and calls externals

Each kernel (API call, blockchain op, data transform) is executed by an Executor

<figure><img src="/files/G7kwK7PxIEPTlQwfTA2P" alt=""><figcaption></figcaption></figure>

#### Step 7 — Attestor signs the final result

The Attestor monitors network traffic, derives ephemeral keys, and cryptographically signs the final result.

<figure><img src="/files/SsmYDICI1KlBIw17Mdrf" alt=""><figcaption></figcaption></figure>

#### Step 8 — KRNL Node sends the UserOps to the Relayer/Bundler&#x20;

The signed execution proof is wrapped into a user operation (userOp) and handed off to the external bundler for blockchain submission.

<figure><img src="/files/soOmnkfm4ctPsdnnNtAF" alt=""><figcaption></figcaption></figure>

#### Step 9 — Bundler forwards the UserOps after validation to designated SCA

The bundler checks proof validity, batches ops if needed, optimizes gas usage, and submits the userOp to the EntryPoint/SCA for on-chain processing.

<figure><img src="/files/c2RAUWTIWC6XVWFyZ4Ut" alt=""><figcaption></figcaption></figure>

#### Step 10 — SCA sends the fees to KRNL Vault & Execute the target smart contract

On-chain, the SCA verifies the attestor’s signature, atomically transfers execution fees to KRNL-Vault, and calls the target smart contract with the verified result.

<figure><img src="/files/BnxbltCM1Lwtt9NruXiq" alt=""><figcaption></figcaption></figure>

#### Step 11 — Target Contract updates state / business logic

The target contract executes its logic (e.g., swap, asset update) only after validating the KRNL proof, ensuring trustless correctness.

<figure><img src="/files/QvmBCNS6xTg0LExj4dsO" alt=""><figcaption></figcaption></figure>

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.krnl.xyz/getting-started/how-does-kos-work.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
