Template payment-upon-iot@0.4.1

Contract ^0.12.0 0737f5deb4ada97cdcac6b66446ad537ddfd8a724140f6c04215b8c865dd7430

This is a payment contract that pays out a fixed amount each time a button is pressed.

Download Archive Open in Template Studio Open in VSCode Web

Payment upon IoT Button Press

This is template pays out a fixed amount each time a button is pressed.

It responds to:

  • single press : increments a counter by 1
  • double press : decrements a counter by 1
  • long press : pays out based on the current counter and resets the counter to 0

Sample

            Upon long button press, "Dan" shall pay to "Grant" 10 USD for each short button press. A maximum of 5 payments may be made before this contract is COMPLETED.

Note: to undo a short button press the buyer may double-press the button.
          

Model Dependencies

Technical Integration

Please refer to the Cicero documentation for details and examples of how to integrate a call to a Cicero template into your application.

View the Latest code for this template on on GitHub.

Sample Instance

{
    "$class": "org.accordproject.payment.iot.PaymentUponButtonContract",
    "contractId": "52ae5173-804a-4d27-93c7-87ec05f2bba8",
    "buyer": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "Dan"
    },
    "seller": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "Grant"
    },
    "amountPerUnit": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 10,
        "currencyCode": "USD"
    },
    "paymentCount": 5
}

State Types

Type Sample JSON
org.accordproject.payment.iot.CounterState
{
    "$class": "org.accordproject.payment.iot.CounterState",
    "status": "COMPLETED",
    "counter": 187.799,
    "paymentCount": 250.528,
    "stateId": "2aa31b10-8942-11e9-b9ba-87d1cf618bec"
}

Request Types

Type Sample JSON
org.accordproject.iot.DoubleButtonPress
{
    "$class": "org.accordproject.iot.DoubleButtonPress",
    "serialNumber": "Et amet.",
    "batteryVoltage": "Eiusmod labore do.",
    "transactionId": "2aa27ed1-8942-11e9-b9ba-87d1cf618bec",
    "timestamp": "2019-06-07T12:34:48.765-04:00"
}
org.accordproject.iot.LongButtonPress
{
    "$class": "org.accordproject.iot.LongButtonPress",
    "serialNumber": "Ut nisi mollit esse.",
    "batteryVoltage": "Proident est tempor.",
    "transactionId": "2aa27ed2-8942-11e9-b9ba-87d1cf618bec",
    "timestamp": "2019-06-07T12:34:48.765-04:00"
}
org.accordproject.iot.SingleButtonPress
{
    "$class": "org.accordproject.iot.SingleButtonPress",
    "serialNumber": "Irure nulla commodo non.",
    "batteryVoltage": "Pariatur nulla do ea.",
    "transactionId": "2aa27ed0-8942-11e9-b9ba-87d1cf618bec",
    "timestamp": "2019-06-07T12:34:48.765-04:00"
}
org.accordproject.payment.iot.MonetaryAmountPayment
{
    "$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 85.581,
        "currencyCode": "AFN"
    },
    "transactionId": "2aa27ed3-8942-11e9-b9ba-87d1cf618bec",
    "timestamp": "2019-06-07T12:34:48.765-04:00"
}
org.accordproject.signature.ContractSigned
{
    "$class": "org.accordproject.signature.ContractSigned",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#5745",
    "transactionId": "2aa257c0-8942-11e9-b9ba-87d1cf618bec",
    "timestamp": "2019-06-07T12:34:48.764-04:00"
}

Response Types

Type Sample JSON
org.accordproject.cicero.runtime.Response
{
    "$class": "org.accordproject.cicero.runtime.Response",
    "transactionId": "2aa2ccf3-8942-11e9-b9ba-87d1cf618bec",
    "timestamp": "2019-06-07T12:34:48.767-04:00"
}

Events Types

Type Sample JSON
org.accordproject.base.Event
{
    "abstract": "this is an abstract type"
}
org.accordproject.cicero.runtime.PaymentObligation
{
    "$class": "org.accordproject.cicero.runtime.PaymentObligation",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 20.52,
        "currencyCode": "RSD"
    },
    "description": "In aliqua incididunt velit.",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#4720",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#7957",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#5520",
    "deadline": "2019-06-07T12:34:48.772-04:00",
    "eventId": "2aa39040-8942-11e9-b9ba-87d1cf618bec",
    "timestamp": "2019-06-07T12:34:48.772-04:00"
}