# Vault

The **KRNL Vault** is the economic backbone of the protocol — the component that ensures workflows not only execute securely but also settle fairly. Executors may compute, attestors may prove, but the Vault handles the **money flows**: billing, fee collection, storage, and distribution.

By integrating with Ethereum standards like **EIP-7702** (delegated accounts) and **EIP-4337** (account abstraction), the Vault makes billing seamless, flexible, and fully automated. This ensures developers can focus on building while the protocol transparently handles value exchange.

### Role in the Protocol

* **Billing Engine** – Enforces payment flows for every workflow execution.
* **Fee Collector** – Captures protocol fees, gas fees, and service costs.
* **Distributor** – Routes funds to node operators, executor builders, kernel providers, and the protocol treasury.
* **Economic Guardian** – Prevents underpayment, double-spending, and ensures sustainability via transparent fee policies.

### Billing System with EIP-7702 + EIP-4337

The Vault leverages Ethereum’s most advanced account standards to handle payments:

#### **EIP-7702: Delegated Accounts**

* Lets an **EOA (Externally Owned Account)** delegate authority to a **Smart Contract Account (SCA)**.
* SCAs can sign and pay for workflow executions on behalf of the user.
* Supports **dual transactions**:
  1. The **workflow execution** itself.
  2. The **corresponding payment** into the Vault.
* Benefits:
  * Users don’t have to manually juggle fee payments.
  * Developers can enforce billing policies at the account level.

#### **EIP-4337: Account Abstraction**

* SCAs function as **programmable wallets**, enabling meta-transactions.
* Supports:
  * **Bundlers**, who relay batched transactions into the chain.
  * **Paymasters**, who can sponsor gas fees for users.
* Benefits:
  * Smooth UX: users don’t need ETH for gas.
  * Flexible billing: fees can be paid in stablecoins or other ERC-20s.
  * Gas optimization: multiple workflow steps can be batched into a single transaction.

Together, **7702 + 4337 turn KRNL billing into a self-contained system**: users delegate, SCAs enforce, Vault collects, and everything is cryptographically verifiable.

### Fee Structure

Every workflow execution incurs three categories of cost:

**Total Execution Cost = Platform Base Fee + External Service Costs + Gas Costs**

1. **Platform Base Fee**
   * Paid to the Vault for using KRNL infrastructure.
   * Funds node operators, executor builders, and protocol maintenance.
2. **External Service Costs**
   * APIs, off-chain data providers, and kernel services each have their own costs.
   * Automatically collected and routed to the correct provider.
   * Enables long-tail API providers to monetize directly within KRNL.
3. **Gas Costs**
   * Native Ethereum gas fees for on-chain verification and settlement.
   * Can be sponsored by developers (via Paymasters) or paid directly by users.

### Distribution of Fees

The Vault executes **automated, rules-based distribution**:

* **Node Operators** – Paid for running KRNL-Nodes that execute workflows and provide computational resources.
* **Executor Builders** – Receive rewards when their executors are used inside workflows.
* **Protocol Treasury** – Funds governance, ecosystem incentives, audits, and long-term development.

This ensures that every contributor to the ecosystem is rewarded **fairly and transparently**.


---

# 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/core-concepts/vault.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.
