Please report issues and contribute improvements on GitHub!

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

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": "96a1d04b-b269-44a6-b348-242c021882a7",
    "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": 9.717,
    "paymentCount": 109.742,
    "stateId": "9f804ad1-60ab-11e9-ba69-a3cec1fc66e2"
}

Request Types

Type Sample JSON
org.accordproject.iot.DoubleButtonPress
{
    "$class": "org.accordproject.iot.DoubleButtonPress",
    "serialNumber": "Deserunt exercitation deserunt qui.",
    "batteryVoltage": "Duis quis.",
    "transactionId": "9f7fae90-60ab-11e9-ba69-a3cec1fc66e2",
    "timestamp": "2019-04-17T00:56:24.313+00:00"
}
org.accordproject.iot.LongButtonPress
{
    "$class": "org.accordproject.iot.LongButtonPress",
    "serialNumber": "Ut mollit.",
    "batteryVoltage": "Laborum velit reprehenderit.",
    "transactionId": "9f7fae91-60ab-11e9-ba69-a3cec1fc66e2",
    "timestamp": "2019-04-17T00:56:24.313+00:00"
}
org.accordproject.iot.SingleButtonPress
{
    "$class": "org.accordproject.iot.SingleButtonPress",
    "serialNumber": "Exercitation tempor aliqua ex officia.",
    "batteryVoltage": "Occaecat occaecat.",
    "transactionId": "9f7f8780-60ab-11e9-ba69-a3cec1fc66e2",
    "timestamp": "2019-04-17T00:56:24.312+00:00"
}
org.accordproject.payment.iot.MonetaryAmountPayment
{
    "$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 60.214,
        "currencyCode": "VUV"
    },
    "transactionId": "9f7fae92-60ab-11e9-ba69-a3cec1fc66e2",
    "timestamp": "2019-04-17T00:56:24.313+00:00"
}
org.accordproject.signature.ContractSigned
{
    "$class": "org.accordproject.signature.ContractSigned",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#7183",
    "transactionId": "9f7f6070-60ab-11e9-ba69-a3cec1fc66e2",
    "timestamp": "2019-04-17T00:56:24.311+00:00"
}

Response Types

Type Sample JSON
org.accordproject.cicero.runtime.Response
{
    "$class": "org.accordproject.cicero.runtime.Response",
    "transactionId": "9f7ffcb2-60ab-11e9-ba69-a3cec1fc66e2",
    "timestamp": "2019-04-17T00:56:24.315+00: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": 34.642,
        "currencyCode": "NZD"
    },
    "description": "Elit minim reprehenderit.",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#3856",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#7935",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#1354",
    "deadline": "2019-04-17T00:56:24.318+00:00",
    "eventId": "9f8071e0-60ab-11e9-ba69-a3cec1fc66e2",
    "timestamp": "2019-04-17T00:56:24.318+00:00"
}