Welcome to this short tutorial where we'll explore how to design and deploy a smart contract using Marlowe. In this guide, we'll create a simple survey contract that records a participant response on the blockchain and rewards them with an NFT.
The survey will consist of 5 questions. The first 4 are statements that you need to agree or disagree and the 5th question is a text-based answer.
The questions are:
To design the contract we'll use the Blockly editor in the
Marlowe Playground. The
questions will be modeled using Choice Action
. Each
question will be answered by the
Address $SURVEY_PARTICIPANT_ADDR
participant before a
parameterized answer timeout
. If the contract timeouts
we close it.
Create the 5 questions blocks with the following parameters:
Choice Name | Bounds |
---|---|
answer1 | [1 - 5] |
answer2 | [1 - 5] |
answer3 | [1 - 5] |
answer4 | [1 - 5] |
answer5 | [1 - 1099511627775] |
Each question block should resemble the following example:
After the questions, the $CUSTODIAN_ADDR
participant
will deposit 1
Token "6fcbab5bb175b420cd060edb63af74c5b3d4687163f282ddc5377dd3"
"SurveyReward"
directly into the survey participant account before a parameterized
reward timeout
and then close the contract. After the
contract is closed, the payment of the reward token will be made
automatically.
After you have created the contract, send it to simulation and check
that there is only one path to receive the
SurveyReward
, which is to answer the 5 questions and
for the custodian to make the deposit.
Set the reward timeout bigger than the answer timeout way far in the
future, download the contract as survey.json
After you download the contract, you can upload it here: