Created
December 11, 2018 04:24
-
-
Save MikeD123/4c3cf9336f9a47d52d7e5f8e2dee7e59 to your computer and use it in GitHub Desktop.
Atomic Swap Example from MakerDAO chat for BTC used as collateral.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://chat.makerdao.com/channel/collateral-discuss?msg=Ykdeb2tByKgxCMwkX | |
**Hopefully this example might help conceptualize it!** | |
This can be done and it's done typically from utilizing atomic swaps. An algorithm for doing a commit/reveal of `x`. | |
Example of Mike with BTC and you have ETH. You would like to swap your 30 ETH for 1 BTC. | |
You setup a smart contract on ETH. It is going to be send 30 ETH to my address (*0x12345*) if I fill in the blanks on the following equation. | |
You have a secret password, and you SHA256 hash of that password. E.g. `password = maker` (but you don't tell me that) | |
`transfer 30 ETH to 0x12345 IF SHA256(x) = 878c240fd717f39d8cec9f7a5cf936873ffcc0757beef703ad2c5f9ed1890344 | |
Otherwise, just send me the money back after 2 days` | |
On the bitcoin chain, Mike does similar. | |
``` | |
transfer 1 BTC to aviv's address (1mn8KH) IF SHA256(x) = 878c240fd717f39d8cec9f7a5cf936873ffcc0757beef703ad2c5f9ed1890344 | |
Otherwise, just send me the money back after 1 day | |
``` | |
Aviv and Mike have set their transactions up, and checked that things all looks good. | |
Aviv then goes to the bitcoin transaction... It's set to goto his wallet only if the equation is satisfied. Remember, it's a secret password that only you know. But we both are certain that the SHA256(x) = 878c240fd717f39d8cec9f7a5cf936873ffcc0757beef703ad2c5f9ed1890344. | |
You put in the password... | |
SHA256(maker) = 878c240fd717f39d8cec9f7a5cf936873ffcc0757beef703ad2c5f9ed1890344 😃 Success! You now have 1 BTC. Thanks! | |
When you do that... You are revealing the value of x to me. | |
You got your 1 BTC. | |
I take the `x` value to your smart contract and hopefully you have not ripped me off and faked it somehow... | |
"Password for this smart contract is `maker`" | |
SHA256(maker) = 878c240fd717f39d8cec9f7a5cf936873ffcc0757beef703ad2c5f9ed1890344 😃 Success! You now have 30 ETH. Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment