Inspiration

The era of centralized exchanges is about to end. Last year, during the QuadrigaCX fiasco, 110 000 of my canadian peers were affected, some being close friends, totaling more than $100 millions in losses. Crazy thing is, this is only a drop in the bucket when talking about crypto exchanges being hacked and/or ill-intentionned and user's fund being ripped away.

LinkSwap is the first step towards a truly trustless way to trade Ethereum with Bitcoin, for which I believe there is a great demand.

How it works

LinkSwap allows two users to create and agree to a contract where User-A trades Ethereum for User-B's Bitcoin in a peer-to-peer fashion.

Create contract User-A (ETH trader) creates a contract with an offer (ETH), a request (BTC) and a requested collateral (ETH).

Accept contract User-B (BTC trader) can then accept the contract by depositing the ETH collateral. He then has 4 hours to complete the trade, during which User-A cannot withdraw his funds.

External payment - BTC transaction User-B then proceeds to send the exact BTC amount to the User-A's BTC address in a single transaction.

Contract fullfillment After at least 6 confirmations, User-B uses the transaction hash to trigger a validation of his payment in the contract.

Contract validation Using the Honeycomb Oracle and Tatum's api, the BTC transaction is validated and User-B receives his ETH.

How I built it

A single contract currently deployed here on Ropsten https://ropsten.etherscan.io/address/0x3f458ebe40f6fa1bc8546884dfb82b6becb2546d handles all the logic for many contracts using the requester's BTC address as an identifier. The Honeycomb's Oracle uses data from the BTC Testnet https://live.blockcypher.com/btc-testnet.

Honeycomb's example project was used as a bas for the client, which has been deployed using _ gh-pages _.

See the ReadMe for a more thorough explanation of how it all works.

Challenges I ran into

The contract's functions are currently quite costly to call, especially the fullfillment call due to value type conversions.

The BTC adress is currently trimmed down to 32 characters (during the expected vs result obained via oracle only) due to a current technical limitation with Chainlink oracles. This is quite bad for the BTC Testnet since addresses are very long (40 chars). On BTC mainnet, addresses are often 26-34 char so this limitation could be worked-around.

Currently, 3 different calls are made to the Honeycomb Oracle to fetch all three needed informations for validation. A single call would be better.

Accomplishments that I'm proud of

  1. It works!!!
  2. I believe that my app, pushed a bit further, could be used by many people.
  3. I believe that this app is the closest thing to a truly decentralized swap between BTC an Ethereum.

What I learned

I've learned about a few current limitations of oracle responses (max length of 32 characters, multiple calls needed for multiple responses).

I also furthered my knowledge about solidity in general and how to handle the different data types and their comparison.

What's next for LinkSwap

I will do my best to make it easier to use, less costly and more secure.

Built With

Share this project:

Updates