Skip to main content
Hugo’s IT journal Hugo's IT journal

Atomic cross chain swap between Hyperledger Fabric and Ethereum

·
blockchain hyperledger crosschain

https://www.youtube.com/watch?v=j_j2MiAxUvY&list=PL0MZ85B_96CEmmy0C6NF52ZCMNcY1Wryf

Methods>

Methods #

Wait until the transaction is completely settled>

Wait until the transaction is completely settled #

not practical and safe

Hashlock>

Hashlock #

The transaction is partially complete

Settle once the sender publishes the key on the blockchain.

Cons>

Cons #

  • hugo cannot refund if kevin does not response
Timelock>

Timelock #

  • hugo made a partial transaction that the btc can be claimed by kevin within n number of blocks
  • if the transaction is expired, hugo can claim back the fund
Cons>

Cons #

  • the claims need to execute manually
HTLC (Hash Time Lock Contract)>

HTLC (Hash Time Lock Contract) #

Combine two locks: (and)

  • claim within n number of blocks
  • the key is revealed on the blockchain
Steps in a cross chain swap>

Steps in a cross chain swap #

Timestamp: 55:36

Example: btc -> eth swap from hugo to kevin

assume that Hugo has a key (secret that only Hugo will know) 1234 with hash 4567

Hugo and Kevin will not make transactions directly

They will send the fund to the contract instead

THe contract will hold the eth and btc for Hugo and Kevin

There are 2 separate contracts

  • one is in btc (let’s say Contract A)

  • the other is in eth (let’s say Contract B)

  • hugo sent btc to the Contract A in btc network

Transaction:

FieldValue
Fromhugo
Value10btc
Tokevin
Hash4567
  • Kevin sent eth to the Contract B in eth network
FieldValue
Fromkevin
Value134eth
Tohugo
hash9876
  • Hugo observed that kevin has funded eth to Contract B. then he will submit his key 1234 in btc network, btc send to kevin by the Contract A
  • same as kevin, he submits his key 9876 in eth network, eth sent to hugo by the Contract B
Problem>

Problem #

  • semi-trusted
    • we assume Hugo and Kevin can see each other on each chain
    • if the access right is changed during the transaction…let say hugo can revoke kevin on eth network..then the transaction fails (this happens on hyperledger as it can have access control but it is not possible on btc and eth)