Skip to content

Latest commit

 

History

History
84 lines (54 loc) · 2.6 KB

File metadata and controls

84 lines (54 loc) · 2.6 KB

Token Transfer

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.

⛓ On-chain

Aiken

🔌 Prerequirements

🪄 Test and build

cd onchain/aiken
aiken check
aiken build

📄 Off-chain

Java Cardano Client Lib

This 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.

Prerequisites

Before running the code, ensure you have the following tools installed:

1. Install JBang

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.

2. Install and Start Yaci DevKit

You need to download and start the Yaci DevKit. This can be done using either the Docker version or the NPM distribution.

a. Docker Version:

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 --start
b. NPM Distribution:

Follow 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.

Running the Code

To run the code, use the following command:

cd offchain/ccl-java
jbang TokenTransfer.java

Verify the Output

After 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