How to Trade KRC-20

KRC-20 Atomic Swaps

With the support for Partially Signed Kaspa Transactions (PSKT), it becomes possible to swap KRC-20 tokens for Kaspa's native cryptocurrency, $KAS. You can get more information by reading this:

On-Chain Listing

  1. P2SH-LIST for placing orders and P2SH-SEND for buying orders are generated based on the public key of the token holding address.

  2. The operation for placing an order (OP) is 'list':

    {"p":"KRC-20","op":"list","tick":"test","amt":"292960000000"}
  3. The 'Reveal' output corresponds to the buying operation OP, which is P2SH-SEND:

    {"p":"krc-20","op":"send","tick":"test"}
  4. After successfully executing the placing order OP, the corresponding amount of tokens will be bound to the UTXO of the buying OP

  5. The indexer will track the spending of the buying UTXO to automatically trigger buying or cancellation operations.

  6. When spending P2SH-SEND but there is no output 2, it is defined as a cancellation operation, and the tokens will be returned to the original address

  7. Requirements for the P2SH-SEND script:

    • No P1 parameter

    • JSON in fixed order

    • No spaces

    • The 'tick' name should be in lowercase, all other characters in lowercase.

Off-Chain Pricing

  1. The seller sets the selling price and the address to receive KAS in the market system.

  2. The market system automatically constructs and stores PSKT transaction data where Input 1 is the UTXO from the buy order, and the amount of KAS for Output 1 is the selling price.

  3. Input 1 uses the signature mode SIG_HASH_SINGLE | SIG_HASH_ANY_ONE_CAN_PAY for signing.

On-Chain Transaction Completion

  • The buyer selects an order in the market system to proceed with payment.

  • The market system constructs a complete transaction based on the PSKT data of the order (adding the necessary additional inputs and outputs), and requests the buyer to sign it.

  • Input 2 and any other inputs are signed using the standard SIG_HASH_ALL mode.

  • Output 2 is the address where the buyer will receive the tokens.

Last updated