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.
Make sure to have Metamask installed!
The contract is currently deployed here on Ropsten, and uses data from the BTC Tesnet.
In this scenario, Alice is the Ethereum trader and Bob is the Bitcoin trader.
- A never used before BTC address
- The number of offered ETH
- The requested amount of BTC
- A possible ETH collateral (to avoid Bob from freezing her funds without consequences)
- Coincidently, his ETH adress is the only one who can receive Alice's ETH if Alice receives her requested BTC
- Bob should then read the contract to validate that he "got the spot"
- Bob now has 4 hours to proceed to the BTC payment to Alice
On the BTC chain, Bob proceeds to send AS A SINGLE TRANSACTION the EXACT AMOUNT of requested BTC to Alice
- Bob must take note of the transaction hash (id) and wait for at least 6 confirmations
- Nb. confirmations (must be > 6)
- voutAddress (must be equal to Alice's BTC address)
- voutValue (must be equal to Alice's requested BTC amount)
- If all is good, Bob receives his collateral back along with Alice's ETH
- The contract hasn't been accepted yet
- Alice receives her balance back
- The contract has been accepted but more than 4 hours has passed withouth fullfillment
- Alice receives her balance back along with the ETH collateral
- Once cancelled, the Contract's information cannot be read anymore
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.
-
Sign up to the Honeycomb marketplace to access the job listings
-
Install npm
-
Install truffle globally using:
npm install -g truffle
-
Install the Metamask add-on to your browser and create a wallet. Note down the mnemonics. Fund it with Ropsten ETH and Ropsten LINK.
-
Create an Infura account, get an endpoint URL for the Ropsten testnet and note it down.
-
Install nv to load the environment variables
-
(Optional) Install Visual Studio Code
-
Clone this repo
-
Install the dependencies:
npm install
- Create the file that you are going to enter your environment variables:
cp .env.example .env
-
Open the newly created
.envfile and enter RPC_URL and PRIVATE_KEYS you noted earlier. -
Deploy the contract (Ropsten LINK will be transferred from your wallet to the contract automatically during deployment)
nv .env npm run migrate:live
Fund the Deployed Contract
nv .env npm run script-1(User 1) - Create a Swap Contract
nv .env npm run script-2(Anyone) - Read a Swap Contract
nv .env npm run script-3(User 2) - Accept a Swap Contract
nv .env npm run script-4(User 2) - Fulfill a Swap Contract
nv .env npm run script-5(User 2) - Request nbConfirmations
nv .env npm run script-5.1(User 2) - Request voutAddress
nv .env npm run script-5.2(User 2) - Request voutValue
nv .env npm run script-5.3(User 1) - Cancel a Swap Contract
nv .env npm run script-6Simply go into the client folder and follow the instructions




