A holistic look at the possibilities

Ethereum's smart contracts have taken center stage in the crypto world, becoming the go-to paradigm for decentralized programming. With just a simple call on the Uniswap contract, Alice can easily swap her ETH for USDT. This swap either succeeds or reverts to its original state, leaving no room for ambiguity. It's the epitome of an atomic transaction powered by smart contracts.

Such atomic transactions are theoretically possible because of HLTC.

Hashed Time-Locked Contracts(HTLC) was first proposed by Bitcoin developers Christian Decker and Rusty Russell in 2015. It can address trust issues between trading parties. If both parties send transactions, they only need to reveal the "key" to the password lock to simultaneously unlock both parties' funds. If one party doesn't proceed with the transaction, the funds can be reclaimed by the sender after a timeout. This represents another atomic transaction programming paradigm.

Compared to smart contract-based atomic transactions, HTLC has the following characteristics:

  1. Time flexibility: Unlike smart contracts that must be completed within a single block, HTLC allows for asynchronous atomic transactions, giving parties ample time to transact.

  2. Space flexibility: Smart contracts must execute transactions within the same chain, while HTLC enables cross-chain transactions, even between BTC and ETH.

  3. Content flexibility: HTLC ensures the security and reliability of transactions while allowing parties to freely determine the trade's content.

  4. Lower security risks: With HTLC, parties' business logic remains off-chain, reducing exposure to potential attacks and allowing for more robust security measures.

BCDEX Network is building a fully decentralized, non-custodial, and oracle-free protocol based on HTLC between Bitcoin and other blockchains. Developers can quickly create cross-chain asset trading dApps, lending dApps, and NFT dApps on BTC mainnet, Lightning Network, EVM, and other programmable blockchain networks.

HLTC mechanism

HTLC (Hashed Time-Locked Contracts) work with a simple concept: a transaction contains two conditions:

  1. Providing the correct password unlocks (spends) the transaction's funds.

  2. If the funds remain unspent after a certain period, the sender can retrieve them.

This mechanism forms the foundation for peer-to-peer (P2P) trading.

Imagine Alice wants to exchange her BTC for Bob's ETH:

  1. Alice sends a transaction with an HTLC script to Bob.

  2. Bob verifies the transaction, extracts the password's hash value, and sends Alice an ETH transaction with the same hash value as the unlocking condition.

  3. Alice sees Bob's transaction, confirms its validity, and uses her password to claim Bob's ETH.

  4. Bob, now having Alice's password, can immediately claim Alice's BTC.

No third-party witnesses are needed in this trustless process. The mechanism is versatile and can facilitate cross-chain asset swaps between virtually any blockchains.

BCDEX Network is a P2P trading network built on HTLC, consisting of exchange protocols, order protocols, and wallet interaction protocols. Technically, BCDEx can support Bitcoin mainnet, Lightning Network, ETH and EVM-based chains, and other programmable blockchains for P2P swaps. The exchange protocol is responsible for implementing the aforementioned Alice-Bob transaction process on these networks.

Users can engage in P2P trades based on the exchange protocol, similar to OTC trading, and use BCDEx as a seamless, efficient value exchange tool. However, if Alice and Bob don't know each other, they need a public order book for fast trade matching - enter BCDEx's order network.

To make the entire process as smooth and user-friendly as DeFi while maintaining self-custody wallets, BCDEx trading protocol must be integrated into wallets. This ensures a seamless, coherent trading experience.

P2P Exchange Protocol

Building on the foundation of HTLC, we can facilitate the exchange of native BTC on Lightning Network or mainnet with assets on smart contract-enabled blockchains. This exchange is completed through asynchronous atomic transactions. Trading parties verify each other's payment information and either confirm to complete the transaction or reject it, causing the order to time out and be canceled.

BCDEx provides corresponding exchange protocols for peer-to-peer transactions between different assets, allowing trading parties to exchange assets without trust. These protocols form the basis of BCDEx.

Currently, we've built peer-to-peer exchange protocols for these assets:

a. Between Lightning Network BTC and EVM-compatible chain assets

b. Between Lightning Network BTC and mainnet BTC

c. Among EVM-compatible chain assets

d. Between mainnet BTC and Ordinals protocol assets

Order Book Protocol

Smart contracts are excellent for online global storage, allowing all transaction participants to complete data exchange based on smart contracts, i.e., order matching. BCDEx stores orders from different chains in corresponding on-chain order contracts and has implemented the following protocols based on the order protocol:

a. Order placement protocol: Buyers/sellers can deposit quotes and assets into the contract to complete order placement. The counterparty can complete the transaction separately, even when the order placer is offline. By querying order information in the contract and performing order-taking operations, order matching is completed.

b. Market maker quoting protocol: To facilitate multiple, batch, and automated order placements by market makers, users can create quoting contracts, setting trading strategies within the contract, such as maximum/minimum transaction amounts, slippage curves, quotes, and other features.

c. Cross-chain exchange routing based on multi-chain orders: Market maker A provides exchange services between BTC-ETH, while market maker B provides exchange services between BTC-BSC. When a user wants to exchange BSC's BTCB for ETH's WBTC, they can place orders to both A and B within the order protocol, completing two exchanges in one step and achieving cross-chain routing.

Application Scenarios

Based on BCDEx, we can connect BTC with the existing ETH ecosystem, introducing on-chain BTC into DeFi. We imagine that BCDEx can help developers build some potential applications:

a. Cross-chain DEX

A cross-chain DEX dApp can be easily built based on the C2C exchange protocol or order protocol. This cross-chain DEX does not have liquidity pools, making it safer and more reliable than current cross-chain bridges.

b. BTC Cross-chain Bridge

Fast exchange between mainnet BTC and other chains' WBTC can be achieved, simplifying the traditional process of going through exchanges.

c. Payment Channels for Lightning Network Wallets

The Lightning Network can quickly complete transfers, but BTC's price fluctuates significantly, making stablecoins more suitable for traditional retail and payment settlement scenarios. Using multi-chain routing exchange protocols, buyer's Lightning Network payments can be converted into USDC for the merchant.

d. NFT Market on BTC

The exchange protocol allows for mainnet BTC and Ordinals protocol "NFT" inscription exchanges, and the order protocol supports order placement operations. Developers can build an OpenSea-like marketplace on BTC.

Last updated