visit
A Real Atomic Swap Between Viacoin and Litecoin
Crypto, Crypto, Crypto ,this is what most talk about nowadays , the demise of crypto, the revolution of crypto, but in the post we are not going to talk about it but rather do it , use it .
I will show you how atomic swap works in practice , the logic behind them from code point of view , and the flow of execution to achieve the end result which is :Alice owns Viacoin , Bob on the other hand is a strong Litecoin advocate but he wantsViacoin because he believes it has a bright future , how can Alice & Bob exchange an amount of their stash for the other without going trough a third party ?The answer is , HTLC in short . Put it simply, a Hashed Time-lock Contract is a non-Turing complete contract , that works like a puzzle with a secret key but requires the solver (in this case Bob ) to provide the key before X time is elapsed otherwise he forfeits the ability to claim the reward,returning it to the the initiator of the contract . A Hash-lock is a “transaction puzzle” that satisfies a condition , the input data hash is equal to a hash value from a previous block , in Script (Bitcoin Scripting Language) it looks like this : An atomic cross-chain swap is a hash-locked contract that happens on both blockchains , an initiator will create a contract and lock an amount X of coin Z in it ,the contract is valid for a time period T if a key provides the valid secret it can move the locked coins if this is not done by the end of T the contract is canceled . If you think about it in terms of bitcoin primitives it make sense and it also shows how cryptography makes this operation secure-proof in easy logic . Alice locks some Viacoin in a contract A,Bob locks some Litecoin in a contract B , Alice gives Bob the secret to unlock the locked Viacoins and Bob does the same at the end both Alice and Bob are incentivized to share the secret since if it’s not done by both of them the coins go back to their respective wallets and no exchange happens .