Fork me on GitHub

Template payment-upon-iot@0.0.1

Contract Ergo ^0.9.1 fb8b79d0ecd30724404e2f5f74ab177e0df138fcb2efdd8d8c748b2a8361e410

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 will be made.

Note: to cancel 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": "7a120da1-8e98-4fea-a4a1-74e67a4a5239",
    "buyer": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "Dan"
    },
    "seller": {
        "$class": "org.accordproject.cicero.contract.AccordParty",
        "partyId": "Grant"
    },
    "amount": {
        "$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": 60569,
    "paymentCount": 53323,
    "stateId": "460b48f2-f59f-11e8-984d-cb3b92f8d55e"
}

Request Types

Type Sample JSON
org.accordproject.cicero.runtime.Request
{
    "$class": "org.accordproject.cicero.runtime.Request",
    "transactionId": "460a3780-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.848Z"
}
org.accordproject.iot.DoubleButtonPress
{
    "$class": "org.accordproject.iot.DoubleButtonPress",
    "serialNumber": "Elit eiusmod sint.",
    "batteryVoltage": "Proident.",
    "transactionId": "460afad1-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.853Z"
}
org.accordproject.iot.LongButtonPress
{
    "$class": "org.accordproject.iot.LongButtonPress",
    "serialNumber": "Lorem enim aute ullamco.",
    "batteryVoltage": "Fugiat officia occaecat consectetur.",
    "transactionId": "460afad2-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.853Z"
}
org.accordproject.iot.SingleButtonPress
{
    "$class": "org.accordproject.iot.SingleButtonPress",
    "serialNumber": "Tempor tempor fugiat ipsum aliquip.",
    "batteryVoltage": "Ipsum officia commodo laboris.",
    "transactionId": "460afad0-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.853Z"
}
org.accordproject.payment.PaymentReceived
{
    "$class": "org.accordproject.payment.PaymentReceived",
    "transactionId": "460afad3-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.853Z"
}
org.accordproject.signature.ContractSigned
{
    "$class": "org.accordproject.signature.ContractSigned",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#2103",
    "transactionId": "460aacb0-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.851Z"
}

Response Types

Type Sample JSON
org.accordproject.cicero.runtime.Response
{
    "$class": "org.accordproject.cicero.runtime.Response",
    "transactionId": "460b21e3-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.854Z"
}

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": 38.941,
        "currencyCode": "BBD"
    },
    "description": "Sit dolore deserunt fugiat esse.",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#7160",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#1944",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#5993",
    "deadline": "2018-12-01T19:28:25.855Z",
    "eventId": "460b48f3-f59f-11e8-984d-cb3b92f8d55e",
    "timestamp": "2018-12-01T19:28:25.855Z"
}