Here is a contracts on Cardano Plutus for swapping seal with ada.
This demo is working on a local playground.
The playground docker-compose from maccam912/ppp, The playground is using the code about 3-4 month ago, but is newer than the public playground.
Start the playgroundy
cd playground
docker-compose up
Wait a while, then open https://localhost:8009/ in your favorite browser.
Open in devcontainer in VSCode. Run in terminal:
cabal build
devcontainer config: .devcontainer/devcontainer.json
User can exchange token "Seal" with "Lovelace". This is a simple demo.
Copy the content of src/swapToken.hs
to play ground. Click "Compile" then "Simulate" button.
Wallet 1 want to sell 10 seal for 20 lovelace. Wallet 2 want to buy 10 seal.
Set up the simuation as below, then click Evaluate
.
Then you can see after last transation, wallet 1 got 20 lovelace and wallet 2 got 10 seal.
- Off-Chain
- Send Seal
- Send Lovelace
- Reeder Seal
- Reeder Lovelace
- On-Chain
- Declare Seal
- Declare Loveace
- Exchange Pool
- Validator (only check payment)
- Upgrade to latest plutus (v1.0.6)