The Mesh team present: "An Aiken library to make devs' day-to-day lives 🌤️easier" | Today's contract: Swap

Mesh Swap contract

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. :woman_scientist:Let’s try it!

:white_check_mark: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.

:white_check_mark:Step 2: Go to

:white_check_mark:Step 3: With one of the wallets (User A), go directly to “Initiate Swap”, connect the wallet, and click on the “Initiate Swap” button.

:white_check_mark: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).


:dart:Challenge: try to do it without the Mesh Token. What error message are you getting? What is this message telling you?

:white_check_mark: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”.

:mag_right: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, and see for yourself that relationship.

:white_check_mark: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!

:flashlight: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

:heart:Want to know what we are cooking for this Catalyst Fund 12 and give us your support to keep the :bulb:lights on? Thanks in advance. Catalyst - MeshJS


Mesh: making life :sun_behind_small_cloud:easier for developers.