The Hash Timed Locked Contract (HTLC) involves two users, the owner and the guesser. This contract allows the owner to lock funds within a contract by providing an expiration time and a secret. Others can try to unlock the funds before the expiration by trying to guess the secret. The owner can unlock the funds after the expiration to get the funds out of the contract.
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 simple-transfer.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