Isn’t the Swap contract a manifestation of the understanding and reconciliation that we as Cardano ecosystem want to bring to the world?
Two parties agree, and the contract ensures that both honor the agreement. Its simplicity is only exceeded by the beauty of its logic. At MeshJS, we want to pay tribute to that logic and our beloved Cardano community’s mission with our Aiken’s Swap contract. Let’s try it!
Step 1: Open two *preprod *wallets and fund them with test Adas. The wallets will represent the parties in the agreement. Note: don’t forget to assign collateral to each of the wallets, that way you will have no problem interacting with the contract.
Step 2: Go to https://meshjs.dev/smart-contracts/swap
Step 3: With one of the wallets (User A), go directly to “Initiate Swap”, connect the wallet, and click on the “Initiate Swap” button.
Step 4: Before going with the other wallet (User B) to the “Accept Swap” section, you must first mint a Mesh Token (above the “Initiate Swap” section).
Challenge: try to do it without the Mesh Token. What error message are you getting? What is this message telling you?
Step 5: With the Mesh Token freshly minted and stored in user B’s wallet, it’s time to go to the “Accept Swap” section to make the agreement effective. Refresh the page, go to “Accept Swap”, connect the wallet, and click “Accept Swap”.
Check this out: User A started the swap with 10 test Adas, but User B is receiving much less. It turns out that the contract sends the Mesh Token from User B to User A, and the costs of that sending must be covered by the beneficiary, in this case User B. But beyond that, notice how the two parties in the agreement will live linked forever, by the Mesh Token, in the Cardano blockchain. Query the transaction hash of the swap acceptance at https://preprod.cardanoscan.io, and see for yourself that relationship.
Step 6: Now, let’s make User A cancel a Swap. Start a new Swap (step 3). Once started, refresh the page, go to the "Cancel Swap" section, connect the same wallet with which you started the contract, and click on the “Cancel Swap” button.
And that’s it!
Would you like to take a look at the source code of the contract? For sure!
Go to mesh/packages/contracts/src/swap at main · MeshJS/mesh · GitHub
Want to know what we are cooking for this Catalyst Fund 12 and give us your support to keep the lights on? Thanks in advance. Catalyst - MeshJS