# Atomic Swap

KRC-20 integrates an **Atomic Swap** protocol to enable peer-to-peer exchange between **Layer-1 KAS** and **KRC-20 tokens**. The protocol does not rely on centralized matching, custody, or bridge trust assumptions. Instead, both parties complete the exchange on-chain with atomic semantics — the transfer either settles for both sides simultaneously or fails for both — thereby providing fully decentralized settlement and delivery at the protocol layer.

Atomic Swap is built on **PSKT (Partially Signed Kaspa Transaction)** technology. The core mechanism operates as follows: the seller creates a KRC-20 token sell order. The order is bound by the protocol to a **seller-controlled P2SH address** and its corresponding UTXO. The seller then partially signs the pricing and key order parameters, ensuring the order carries verifiable funding constraints and an unforgeable ownership relationship. The buyer submits the corresponding KAS buy transaction on Layer-1 by completing the seller-constructed transaction data, finalizing the signatures, and broadcasting the transaction. This atomic process synchronizes KAS payment with KRC-20 token delivery, ensuring that settlement and transfer occur simultaneously.

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

Through the combined use of PSKT and P2SH script constraints, an order cannot be independently replayed without the seller’s UTXO, the buyer cannot extract tokens without satisfying the seller’s signature conditions, and the seller cannot withhold token delivery after receiving KAS. As a result, Atomic Swap enables **real-time**, **trustless**, and **secure** exchange and serves as a foundational module for asset trading and cross-layer liquidity within the KRC-20 ecosystem.


---

# 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-kasplex.gitbook.io/krc20/protocols/atomic-swap.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.
