Writing Marlowe with Blockly

You can write Marlowe code directly as Marlowe text, or alternatively use the Blockly visual interface to piece together the parts of the contract. This is a very useful tool for those users who may not have experience in programming editors, and want to build the contracts visually.

To use Blockly follow these steps:

  1. Open the Marlowe Playground.

    You will see a window like this:

landing page

  1. Click the Start coding! button on the bottom left and then select Blockly from the menu.

    You will see a window like this:


  1. You can build contracts by adding components to the Contract block.

    You will see a list of options for forming a contract by clicking Contracts in the menu.


  1. Click Contracts and select a block.

  2. Drag it into the building pane and then fit it into the top-level slot.

    The following example shows how to construct a contract starting with When as its main construct.


  1. Continue building the contract. To build a contract with When, it needs to include one or more actions that trigger the contract. These can be chosen from the Actions menu item.


The following example shows how to construct a Deposit action and fit it into the first gap in the contract that you are building.


  1. Next, insert the following information:

    • who is making the deposit (the party)
    • the value and currency (token) of the deposit
    • whose account it should be deposited to (the recipient).


  1. You can add other actions. For this, choose actions, add them, and fill out information. Respective action will require different types of information. Add the Close tab after Continue as so that the contract closes after making the deposit.

  2. Finally, when all actions are inserted and conditions are added, you can complete your contract by adding a Close tab to the main contract. This shows how the contract should behave in case the deposit is not made before the specified timeout.


© IOHK 2015 - 2022

Cardano Logo

Cardano is an open-source project.

Cardano is a software platform ONLY and does not conduct any independent diligence on, or substantive review of, any blockchain asset, digital currency, cryptocurrency or associated funds. You are fully and solely responsible for evaluating your investments, for determining whether you will exchange blockchain assets based on your own judgement, and for all your decisions as to whether to exchange blockchain assets with Cardano. In many cases, blockchain assets you exchange on the basis of your research may not increase in value, and may decrease in value. Similarly, blockchain assets you exchange on the basis of your research may fall or rise in value after your exchange.

Past performance is not indicative of future results. Any investment in blockchain assets involves the risk of loss of part or all of your investment. The value of the blockchain assets you exchange is subject to market and other investment risks