- The possibility of a safe return of funds to each of the parties if the other party does not comply with the terms of the trade
- Open sources of smart contracts published at GitHub/GitLab or another open repository
- Documentation
- Name and contact information of the contestant for communication (Telegram username, e-mail)
Author - Nail Khafizov, independent software developer.
Ton Crystal
, Native Ether
, Ethereum ERC20
, Bitcoin
Develop an infrastructure that allows users to perform transactions between different blockchains without escrow in an untrusted environment. It will make the exchange market around TON Crystal more secure for OTC transactions.
Atomic Swap — a smart contract technology enables the exchange of one cryptocurrency for another without using centralized intermediaries (such as exchanges). I've learned two ways of swaps:
- By using Hashed TimeLock Contract
- By using Simplified Payment Verification.
HTLC — the most simple. It requires supporting common hash function (e.g. sha256
) from blockchain and TimeLock contract functionality.
+
Сan be fully decentralised
-
Requires side communication between participants and locking money on specific time
SPV requires from one of two blockchains supporting runnig complex smart contracts (e.g. Ethereum
or Ton
) to verify transaction's Merke Proof of transfer.
+
Transfer can be fast and automatic
-
Requires solution to identify the source of the transaction:
mainnet / testnet / side blockchain by using oracles smart contracts / supporting SPV verification by validators.
I chose HTLC, because:
- Time of contest is limited to 3 weeks
- High transmission speed can be achieved through automation Atomic Swap Wallet, which supports SPV verification different blockchains off-chain.
FreeTon: TON-Solidity-Compiler
, Solidity
, JS
for testing
Ethereum: Truffle
, Solidity
, JS
for testing
Bitcoin (Work in progress): bitcoinjs-lib
, JS
./ton
- Atomic Swap Contracts for FreeTon blockchain
./eth
- Atomic Swap Contracts for Ethereum blockchain
./btc
- Atomic Swap Contracts for Bitcoin blockchain
./app
- App for demostrating working of Smart Contracts at testnets. Not used in production, only for learning purpose
initiate
(participant address, amount, secret hash, lock time)
participate
(initiator address, amount, secret hash, lock time)
redeem
(secret)
refund
- Part A have to generate the secret limited by 32 bytes and store it securely. Next, Part A
initiate
and create contract with hash of secret and participant's address. In this contract the locktime should be doubled to avoid scam (e. g.24h * 2 = 48h
). After that, Part A have to send transaction or smart contract address to Part B. - Part B have to verify Part A's contract: participant's address, lockTime, amount, hash of code. If everything is OK — Part B should
participate
and create contract with Part A's secret hash, otherwise Part B can do nothing. Part B should be careful, lockTime should be less Part A's lockTime at the moment of creating contract. After, Part B have to send transaction or smart contract address to Part A. - Part A have to verify Part B's contract. If everything is OK — Part A can
redeem
from Part B's contract and reveal secret, otherwise Part A can wait timeLock and refund his transfer. - Part B should extract secret and
redeem
from Part A's contract.
The most part of steps can be automated by wallet, with the exception of exchange address and transactions
https://www.investopedia.com/terms/a/atomic-swaps.asp
https://github.com/decred/atomicswap
https://medium.com/summa-technology/cross-chain-auction-technical-f16710bfe69f