Fork me on GitHub

Template payment-upon-iot@0.1.5

Contract Ergo ^0.9.1 b6f464c4b30a18468a3fbd579380a1679671902c56671de694ca98a110dda3d1

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": "772e3eac-ae27-42f6-86d7-fdaad61dd593",
    "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": "INITIALIZED",
    "counter": 168.859,
    "paymentCount": 232.66,
    "stateId": "80814a12-f965-11e8-a56a-77a02d989920"
}

Request Types

Type Sample JSON
org.accordproject.cicero.runtime.Request
{
    "$class": "org.accordproject.cicero.runtime.Request",
    "transactionId": "80805fb0-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.771Z"
}
org.accordproject.iot.DoubleButtonPress
{
    "$class": "org.accordproject.iot.DoubleButtonPress",
    "serialNumber": "Nostrud cupidatat sint.",
    "batteryVoltage": "Qui.",
    "transactionId": "8080fbf0-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.775Z"
}
org.accordproject.iot.LongButtonPress
{
    "$class": "org.accordproject.iot.LongButtonPress",
    "serialNumber": "Culpa qui voluptate nisi cillum.",
    "batteryVoltage": "Culpa.",
    "transactionId": "8080fbf1-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.775Z"
}
org.accordproject.iot.SingleButtonPress
{
    "$class": "org.accordproject.iot.SingleButtonPress",
    "serialNumber": "Incididunt.",
    "batteryVoltage": "Id.",
    "transactionId": "8080d4e0-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.774Z"
}
org.accordproject.payment.iot.MonetaryAmountPayment
{
    "$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 44.969,
        "currencyCode": "KZT"
    },
    "transactionId": "8080fbf2-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.775Z"
}
org.accordproject.signature.ContractSigned
{
    "$class": "org.accordproject.signature.ContractSigned",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#6684",
    "transactionId": "8080add0-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.773Z"
}

Response Types

Type Sample JSON
org.accordproject.cicero.runtime.Response
{
    "$class": "org.accordproject.cicero.runtime.Response",
    "transactionId": "80812303-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.776Z"
}

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": 51.927,
        "currencyCode": "PLN"
    },
    "description": "Ex.",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#3162",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#4814",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#0706",
    "deadline": "2018-12-06T14:44:57.778Z",
    "eventId": "80817120-f965-11e8-a56a-77a02d989920",
    "timestamp": "2018-12-06T14:44:57.778Z"
}