Request options for the Build Create Contract Tx endpoint

Hierarchy

  • BuildCreateContractTxRequestOptions

Properties

accounts: AccountDeposits

describe an initial deposit of assets for the accounts in the contract. The key is the address or role name and the value is the assets. These assets will be deposited in the accounts at the creation of the contract, and will come from the contract creator's wallet.

changeAddress: Branded<string, AddressBech32Brand>

The Marlowe Runtime utilizes this mandatory field and any additional addresses provided in usedAddresses to search for UTxOs that can be used to balance the contract creation transaction.

Any change from the creation transaction will be sent here.

collateralUTxOs?: TxOutRef[]

UTxOs provided as collateral in case the Tx built will unexpectedly fail at the submit phase.

Justification

The collateral mechanism is an important feature that has been designed to ensure successful smart contract execution.

Collateral is used to guarantee that nodes are compensated for their work in case phase-2 validation fails. Thus, collateral is the monetary guarantee a user gives to assure that the contract has been carefully designed and thoroughly tested.

Collateral amount is specified at the time of constructing the transaction. Not directly, but by adding collateral inputs to the transaction.

The total balance in the UTXOs corresponding to these specially marked inputs is the transaction’s collateral amount.

If the user fulfills the conditions of the guarantee, and a contract gets executed, the collateral is safe.

metadata?: Metadata

Cardano Metadata about the contract creation.

Properties

Metadata can be expressed as a JSON object with some restrictions: - All top-level keys must be integers between 0 and 2^63 - 1. - Each metadata value is tagged with its type. - Strings must be at most 64 characters long (64 bytes) when UTF-8 is encoded. - Bytestrings are hex-encoded, with a maximum length of 64 bytes.

Metadata aren't stored as JSON on the Cardano blockchain but are instead stored using a compact binary encoding (CBOR). The binary encoding of metadata values supports three simple types:

  • Integers in the range -(2^63 - 1) to 2^63 - 1
  • Strings (UTF-8 encoded)
  • Bytestrings
  • And two compound types:
    • Lists of metadata values
    • Mappings from metadata values to metadata values

      It is possible to transform any JSON object into this schema (See https://developers.cardano.org/docs/transaction-metadata )
minimumLovelaceUTxODeposit?: number

Minimum Lovelace value to add on the UTxO created (Representing the Marlowe Contract Created on the ledger).This value is computed automatically within the Runtime, so this parameter is only necessary if you need some custom adjustment.

Justification

Creating a Marlowe contract over Cardano is about creating UTxO entries on the Ledger.

To protect the ledger from growing beyond a certain size that will cost too much to maintain, a constraint called "Minimum ada value requirement (minimumLovelaceUTxODeposit)" that adjust the value (in ADA) of each UTxO has been added.

The bigger the UTxOs entries are in terms of bytesize, the higher the value if minimum ADA required.

Role Token Configuration for the new contract passed in the contractOrSourceId field.

Participants

Participants (Party) in a Marlowe Contract can be expressed in 2 ways:

  1. By Adressses : When an address is fixed in the contract we don't need to provide further configuration.
  2. By Roles : When the participation is done through a Role Token, we need to define if that token is minted as part of the contract creation transaction or if it was minted beforehand.

Configuration Options

  • When to create (mint)
    • Within the Runtime : At the contrat creation, these defined Roles Tokens will be minted "on the fly" by the runtime.
    • Without the Runtime : before the creation, these Role Tokens are already defined (via an NFT platform, cardano-cli, another Marlowe Contract Created, etc.. )
  • How to distribute
    • Closedly (Closed Roles) : At the creation of contract or before, the Role Tokens are released to the participants. All the participants are known at the creation and therefore we consider the participation as being closed.
    • Openly (Open Roles) : Whoever applies an input (IDeposit or IChoice) on the contract contractOrSourceId first will be identified as a participant by receiving the Role Token in their wallet. In that case, participants are unknown at the creation and the participation is open to any meeting the criteria.
  • With or without Metadata
  • Quantities to create(Mint) : When asking to mint the tokens within the Runtime, quantities can defined as well.

Smart Constructors are available to ease these configuration:

Remarks

  • The Distribution can be a mix of Closed and Open Role Tokens configuration. See examples below.

Example

 //////////////
// #1 - Mint Role Tokens
//////////////
const anAddressBech32 = "addr_test1qqe342swyfn75mp2anj45f8ythjyxg6m7pu0pznptl6f2d84kwuzrh8c83gzhrq5zcw7ytmqc863z5rhhwst3w4x87eq0td9ja"
const aMintingConfiguration =
{ "closed_Role_A_NFT" : mintRole(anAddressBech32)
, "closed_Role_B_FT" :
mintRole(
anAddressBech32,
5, // Quantities
{ "name": "closed_Role_B_FT Marlowe Role Token",
"description": "These are metadata for closedRoleB",
image": "ipfs://QmaQMH7ybS9KmdYQpa4FMtAhwJH5cNaacpg4fTwhfPvcwj",
"mediaType": "image/png",
"files": [
{
"name": "icon-1000",
"mediaType": "image/webp",
"src": "ipfs://QmUbvavFxGSSEo3ipQf7rjrELDvXHDshWkHZSpV8CVdSE5"
}
]
})
, "open_Role_C" : mintRole(openRole)
, "open_Role_D" : mintRole(
openRole,
2, // Quantities
{ "name": "open_Role_D Marlowe Role Token",
"description": "These are metadata for closedRoleB",
image": "ipfs://QmaQMH7ybS9KmdYQpa4FMtAhwJH5cNaacpg4fTwhfPvcwj",
"mediaType": "image/png",
"files": [
{
"name": "icon-1000",
"mediaType": "image/webp",
"src": "ipfs://QmUbvavFxGSSEo3ipQf7rjrELDvXHDshWkHZSpV8CVdSE5"
}
]
})
}

//////////////
// #2 Use Minted Roles Tokens
const aUseMintedRoleTokensConfiguration =
useMintedRoles(
"e68f1cea19752d1292b4be71b7f5d2b3219a15859c028f7454f66cdf",
["role_A","role_C"]
)

See

stakeAddress?: StakeAddressBech32

Marlowe contracts can have staking rewards for the ADA locked in the contract. Use this field to set the recipient address of those rewards

tags?: Tags

Marlowe Tags are stored as Metadata within the Transaction Metadata under the top-level Marlowe Reserved Key (1564). Tags allows to Query created Marlowe Contracts via Get contracts

Properties

  1. They aren't limited size-wise like regular metadata fields are over Cardano.
  2. Metadata can be associated under each tag

Example

const myTags : Tags = { "My Tag 1 That can be as long as I want": // Not limited to 64 bytes
{ a: 0
, b : "Tag 1 content" // Limited to 64 bytes (Cardano Metadata constraint)
},
"MyTag2": { c: 0, d : "Tag 2 content"}};
threadRoleName?: string

The Thread Roles capability is an implementation details of the runtime. It allows you to provide a custom name if the thread role name is conflicting with other role names used.

Default

- the Thread Role Name is "" by default.
usedAddresses?: Branded<string, AddressBech32Brand>[]

The Marlowe Runtime utilizes the mandatory changeAddress and any additional addresses provided here to search for UTxOs that can be used to balance the contract creation transaction.

Remarks

  1. When using single address wallets like Nami, it is not necesary to fill this field.
  2. If an address was provided in the changeAddress field, it is redundant to include it here (but it doesn't fail).

See

version: "v1"

The Marlowe validator version to use.