Skip to content

adalicious/aiken-gift-card

Repository files navigation



Adalicious
Adalicious - Aiken Gift Card

Make a one shot minting and lock contract

What's ThisTechusageLicense


What's This?

This is an example of a gift card. With these contracts you can lock anything and have it be unlockable only with a simultaneously minted NFT. This minted NFT holds the power to unlock the assets and is considered the "gift card".

This starter kit is based on the Gift Card example provided in the Aiken documentation, adapted to work seamless with the Ogmios and Kupo instance provided by Demeter and implemented as a NextJS application.

Reference the official documentation for details about how this starter kit was implemented and the logic behind the validators at the Gift Card example.

Tech

Usage

Setup the required ENV variables for initializing Lucid with Kupos and Ogmios.

  • KUPO_URL
  • OGMIOS_URL
  • NETWORK

We are going to need these extensions to be enabled in your Demeter project:

extensions

For more information about how to manage the extension in your project check the documentation

After the extension is enabled, make sure you are exposing the Http Port to be available for external dApps. The URL provided should be the value to set in your ENVs.

expose-port

NOTE: Don't forget to add the protocol to the URL when setting up your ENV. Kupo will be exposed under https and Ogmios under wss

For the NETWORK ENV variable the possible values are:

  • Preview
  • Preprod
  • Mainnet

Once you configuration is set you can start the project:

Install the dependencies

npm install

Build an run the application in development mode

npm run build
npm run dev

You can access the front-end application in your browser at localhost:3000 .

NOTE: If you are running the application from inside a Cardano Workspace in Demeter you will have to expose the port 3000 for accessing the app in your browser. Make sure you replace the constant value BASE_URL defined in create.tsx with the URL provided by Demeter in your exposed port. ie: const BASE_URL = "{URL provided by Demeter}/redeem";

home

Create Gift Card

For creating a Gift Card first you need to input a name for your token so you can make the contracts:

make-contracts

Once the contracts are applied you will get the Gift Card and Redeem Scripts and you can select how much ADA you want to lock into the gift card

lock-ada

Once you are ready press the CREATE GIFT CARD button. You will be prompted to sign the transaction and the app will wait for the tx to be confirmed.

Once confirmed you will get the tx hash and the redeem URL. The owner of the minted NFT can unlock the ADA in the contract by accessing this URL.

ada-locked

Redeem Gift Card

For redeeming a Gift card you can access the URL generated at the moment of locking ADA, if you are the owner of the minted NFT you will be able to unlock the ADA in the contract.

redeem

Press the REDEEM GIFT CARD button. You will be prompted to sign the transaction and the ADA will be unlocked to your wallet. The application will show the tx hash of the generated transaction.

redeemed

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published