Hello World

Simple lock and unlock assets contract

The Hello World smart contract is a simple lock-and-unlock assets contract, providing a hands-on introduction to end-to-end smart contract validation and transaction building.

There are 2 conditions to unlock the assets:

  • Signer must be the same as the one who locked the assets
  • Signer must provide the message Hello, World!

There are 2 actions (or endpoints) available to interact with this smart contract:

  • Lock assets
  • Redeem assets

Install package

First you can to install the @meshsdk/contracts package:

Initialize the contract

To initialize the contract, we need to initialize a provider, MeshTxBuilder and MeshGiftCardContract.

Both on-chain and off-chain codes are open-source and available on Mesh Github Repository.

Lock Assets

This transaction locks funds into the contract.

The datum must match the representation expected by the validator (and as specified in the blueprint), so this is a constructor with a single field that is a byte array.

Thus, we provide a hash digest of our public key, which will be needed to unlock the funds.

Lock Asset

Lock asset in the contract

Connect wallet to run this demo

No wallets installed

Unlock Assets

There are 2 conditions to unlock the assets:

  • Signer must be the same as the one who locked the assets
  • Signer must provide the message Hello, World!

The validator script for the contract checks that the redeemer is the same as the owner of the datum and that the message is Hello, World!:

Redeem Giftcard

Redeem a gift card given the gift card UTxO

Connect wallet to run this demo

No wallets installed