This smart contract locks a specific crypto asset, defined by its PolicyId and assetName, which can only be spent by a designated receiver. The receiver must sign the transaction to withdraw the asset, and the transaction cannot involve sending other unexpected assets to different addresses. To prevent funds from being permanently locked, the contract also allows anyone to spend UTXOs sent to its address that do not contain the specified asset.
cd onchain/aiken
aiken check
aiken buildThis offchain code is written by using the Cardano Client Lib. It assumes that the addresses are topped up. If you need some tAda, you can get some from the Cardano Testnets Faucet.
To simplify execution, all the code is contained in a single file, which can be run using jbang.
Before running the code, ensure you have the following tools installed:
You can install JBang using various methods:
-
Using SDKMAN:
sdk install jbang
-
Using cURL:
curl -Ls https://sh.jbang.dev | bash -s - app setup
For other installation methods, refer to the JBang installation guide.
Note: If Java is not installed on your machine, JBang will download a Java runtime for you.
You need to download and start the Yaci DevKit. This can be done using either the Docker version or the NPM distribution.
Follow the instructions here.
After installing Yaci Devkit Docker distribution, you can start DevKit in non-interactive mode in just one command:
devkit start create-node -o --startFollow the instructions here.
Important:
When starting the Yaci DevKit using NPM distribution, be sure to include the --enable-yaci-store option with the up command.
To run the code, use the following command:
cd offchain/ccl-java
jbang TokenTransfer.javaAfter running the code, you can verify the output in Yaci Viewer. To access Yaci Viewer in docker distribution, use the following url
http://localhost:5173