The Escrow contract is the trusted intermediary that allows two parties to safely exchange assets, holding them until both parties agree and sign the Tx. Let’s try it!
To do so, you’ll need two preprod wallets (to simulate the two parties in agreement).
Step 1: Go to https://meshjs.dev/smart-contracts/escrow
Step 2: Connect one of the preprod wallets (user B) and mint a Mesh token.
Step 3: With the other preprod wallet (user A), go to “Initiate Escrow”, and initiate it.
Step 4: Refresh the page. With the preprod wallet that holds the Mesh token (user B), go to “Recipient Deposit” and click on “Deposit”.
If you check the wallet, the Mesh token should be gone.
Step 5: Refresh the page and connect the wallet that initiated the Escrow (user A).
Beware: only connect the wallet, don’t mint a new Mesh token again.
Now, go to “Complete Escrow” and click on “Sign Transaction”.
Step 6: Still in “Complete Escrow”, switch to the wallet that deposited the Mesh token (user B). Click on “Complete Escrow”.
If you check user B’s wallet, you’ll notice that 10 tAda have arrived. And if you check user A’s wallet, you’ll see that a Mesh token has arrived.
Step 7: Let’s try the “Cancel Escrow” option. To do so, repeat steps 2, 3, and 4. Next, proceed to “Cancel Escrow” and click on the “Cancel Escrow” button using either wallet (user A or user B).
Would you like to take a look at the source code of the Aiken Escrow contract? For sure!
Go to https://github.com/MeshJS/mesh/tree/main/packages/contracts/src/escrow