{"id":20834619,"url":"https://github.com/apriorit/atomic_swap_dex_demo","last_synced_at":"2026-04-16T15:04:19.689Z","repository":{"id":43235922,"uuid":"267639874","full_name":"apriorit/atomic_swap_dex_demo","owner":"apriorit","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-08T05:29:26.000Z","size":874,"stargazers_count":0,"open_issues_count":13,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T21:32:04.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apriorit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-28T16:27:35.000Z","updated_at":"2020-06-11T08:25:08.000Z","dependencies_parsed_at":"2023-01-24T14:15:09.364Z","dependency_job_id":null,"html_url":"https://github.com/apriorit/atomic_swap_dex_demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apriorit%2Fatomic_swap_dex_demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apriorit%2Fatomic_swap_dex_demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apriorit%2Fatomic_swap_dex_demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apriorit%2Fatomic_swap_dex_demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apriorit","download_url":"https://codeload.github.com/apriorit/atomic_swap_dex_demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243188200,"owners_count":20250453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T00:19:54.884Z","updated_at":"2025-12-24T15:56:43.785Z","avatar_url":"https://github.com/apriorit.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# awesome-dex\n\nThis is a demo prototype, that aims to showcase how Atomic Swaps can be used to build a DEX.\n\nThe project consists of several parts:\n\n- `/contracts/ontology` folder contains Ontology SC and unit tests for it\n- `/contracts/ethereum` folder contains Ethereum SC\n- `/frontend` folder contains simple frontend, that allows interacting with smart contracts mentioned above\n\n## About the demo\n\n#### Setting up\n\n```\ncd frontend\nnpm install\nnpm start\n```\n\nThe demo can be accessed though `localhost:3000`.\nBefore using the demo, please install _Metamask_ extension and set it to Ropsten testnet.\n\n#### Notes\n\nFrontend demo is not a fully-functional DEX, but rather a way to facilitate interaction with smart contracts in order to see, how atomic swaps work.\n\nPrototype interacts with Ontology SC\n(deployed to Ontology testnet on `14972f644a4c43a9e097ee55968f877ce799754d`)\nand Ethereum SC (deployed to Ropsten testnet on `0x6ad25cb063bc6ebbc7a0ed66cbb91aa4c7fad86e`).\n\nWe've got 2 hardcoded users: Alice and Bob. Alice wants to sell some amount of ONT for ETH, and Bob wants to exchange his ETH to ONT.\nPrivate keys and addresses are located on `frontend/src/api/constants` in `users` object.\nPlease, note, that you can use that users, but keep in mind, that they are not guaranteed to have sufficient balance of ETH and/or ONT.\nYou are welcome to recharge those wallets, but it would be best to replace hardcoded data with your own test accounts.\n\nDemo provides _Check order data_ page, that lets checking state of the order.\nBut it can also be handy to monitor what's going on with SC with testnet block explorers:\n\n- _Ontology:_ https://explorer.ont.io/contract/other/4d7599e77c878f9655ee97e0a9434c4a642f9714/10/1/testnet\n- _Ethererum:_ https://ropsten.etherscan.io/address/0x6ad25cb063bc6ebbc7a0ed66cbb91aa4c7fad86e\n\n#### Workflow instruction\n\nTo initiate exchange switch to Alice and to go _Create order_ page.\n\n![Create order page](screenshots/01.png)\n\nWhen transaction is completed, respective amount of ont will be transferred from Alice to smart contract.\nThe following message will appear:\n\n![Create order page](screenshots/02.png)\n\nIt is important to save this values, otherwise access to those locked ONT will be permanently lost.\n\nLet's assume that following data is safely stored by Alice:\n\n```\nHashlock b9d2195fbd4b7a5812498d380b2275e4eb8b939920cc74288fa688f6e0849c93\n\nSecret 97feb4ac885c56dd4bbb454fc1dbb0175e5fe5e66e123d394e83bd357a2d04cf569298d625cbc9799a5db2296e912448\n```\n\nNow it's time for Bob to respond to Alice's order.\nWe assume that Bob knows hashlock and order details already (f.e. through using some public order book aggregator), but that is not significant in terms of our demo.\n\nLet's switch to Bob and go to _Respond to order_ page:\n\n![Respond to order page](screenshots/03.png)\n\nHere Bob inputs hashlock of the order he wants to respond to.\nAmount of ETH to be locked on Ethereum SC from Bob is automatically set from value in corresponding Ontology contract.\n\nNow both Alice and Bob can persuade that order was initiated correctly:\n\n![Check order data](screenshots/04.png)\n\nNotice, how Ontology contract holds Alice's Ontology address (presented in hex) and Ethereum contract holds Bob's Ethereum address.\n\nSay, someone changes his/her mind in any poin of time before locking addresses of other party.\nIn this case, refunding can take place.\nRefund is also possible if other party's address was locked, but only after refund timelock.\n\n![Check order data](screenshots/05.png)\n\nUse refund from Alice's account to refund ONT and from Bob's account to refund ETH.\nRefunding will only work if assets were not claimed by other party.\n\nNow that Bob responded to Alice's order, she should lock buyer Ontology address.\nIt's a good idea to check order data first and verify, that appropriate amount of ETH was indeed locked.\n\nAfter making sure that amount of ETH is sufficient, Alice goes to _Lock buyer address_ page:\n\n![Lock buyer address](screenshots/06.png)\n\nNotice, that Bob's Ontology address (hex representation) is inputted beforehand for convenience.\n\nNow Bob should check order data and make that his Ontology address is correct.\n\n![Check order data](screenshots/07.png)\n\nAfter that Bob goes to _Lock initiator address page_ and locks Alice Ethereum address (inputted beforehand as well).\n\n![Lock initiator address](screenshots/08.png)\n\nExchange is almost completed. At this point revealing secret and claiming assets should take place.\n\nPlease note, that timelocks set in deployed testnet contracts are set to 10 seconds for purposes of quick proof of concept testing.\nIn real DEX timelocks should be 24h and 48h, instead of 10 and 20 seconds in Ethereum and Ontology contracts respectively.\nIt is also unsafe to perform claim after refund timelock time in a real exchange situation.\n\nAlice now ensures, that her Ethereum address is correct:\n\n![Check order data](screenshots/09.png)\n\nShe uses that address to send secret to Ethereum SC and claim her ETH from _Claim ETH_ page:\n\n![Claim ETH](screenshots/10.png)\n\nThe secret was revealed, Bob can get this value from _Check order data_ page:\n\n![Check order data](screenshots/11.png)\n\nBob copies the value of secret and inputs it on _Claim ONT_ page:\n\n![Claim ONT](screenshots/12.png)\n\nThat's it, exchange was performed successfully.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapriorit%2Fatomic_swap_dex_demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapriorit%2Fatomic_swap_dex_demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapriorit%2Fatomic_swap_dex_demo/lists"}