Reserved IP Address°C
03-09-2025
BSV
$33.63
Vol 15.23m
-5.37%
BTC
$83561
Vol 16511.33m
-3.39%
BCH
$369.07
Vol 212.21m
-4.71%
LTC
$100.4
Vol 543.75m
-3.58%
DOGE
$0.17
Vol 1097.29m
-7.9%
Getting your Trinity Audio player ready...

This post was first published on Medium.

Using Hash Time-Locked Contracts

As we have shown before, Ordinals can be seamlessly combined with bitcoin smart contracts. To further demonstrate the power and flexibility of combining them, we lock up an ordinal into a Hash Time-Locked Contract (HTLC) and atomically swap it with bitcoins, allowing trustless trading.

Atomic swap

To swap Ordinals and BSV, we just apply the same atomic swap protocol used to swap BSV and BTC, with two slight differences:

  1. Swap between assets on the same chain, instead of across two different chains. The protocol works the same since it relies on two hash locks having same PINs/preimages, regardless of the blockchains they are running on.
  2. Swap Ordinals tokens rather than native assets such as BTC or BSV.
Bob and Alice setup diagram
Setup

During setup, an ordinal is transferred to a HLTC, whose code we reproduce below.

HLTC contract

Due to its compatibility with Ordinals, the smart contract needs no change at all. It is the same contract as before. It locks up Ordinals, the same way as bitcoins, because both use UTXO model.

The rest of protocol execution is the same as swapping BSV and BTC.

Satoshi and Ordinals atomic swap
Swap

Here is a run for Ordinal #25883457:

Extension

It is straightforward to extend it to atomically swap other pair of assets, as long as they are on chains that support both HLTC and Ordinals, e.g.,

  • Ordinals <-> Ordinals: same chain or different chains
  • Ordinals on Bitcore Core <-> BTC
  • Ordinals on Bitcoin SV <-> BTC
  • Ordinals on Bitcoin Core <-> BSV.

Watch CoinGeek Roundtable Episode 7: 1Sat Ordinals on Bitcoin

Recommended for you

Building a solid ecosystem: Babbage to host BSV Hackathon in Texas
The US$55,000 prize money is up for grabs at the inaugural BSV Hackathon in Austin, Texas, which Babbage will host...
March 3, 2025
GPT-4.5 is not the AGI moment OpenAI teased
While he previously called for lower expectations over GPT-4.5, Sam Altman was lured into dubbing it the closest step to...
March 3, 2025
Advertisement
Advertisement
Advertisement