Please report issues and contribute improvements on GitHub!

Template payment-upon-iot@0.3.0

Contract Ergo ^0.11.1 cd55f97725a1a2256c1fec0f434ebecf70ca4a6a6549fa95a525e391c420fc88

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": "264b6c8e-7c3e-4cf4-8f09-2413435d4556",
    "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": 147.425,
    "paymentCount": 62.804,
    "stateId": "2e747e91-4bae-11e9-8561-af645d56312b"
}

Request Types

Type Sample JSON
org.accordproject.iot.DoubleButtonPress
{
    "$class": "org.accordproject.iot.DoubleButtonPress",
    "serialNumber": "Mollit qui reprehenderit.",
    "batteryVoltage": "Et ut magna quis.",
    "transactionId": "2e73e251-4bae-11e9-8561-af645d56312b",
    "timestamp": "2019-03-21T07:51:48.725+00:00"
}
org.accordproject.iot.LongButtonPress
{
    "$class": "org.accordproject.iot.LongButtonPress",
    "serialNumber": "Non sint laborum mollit minim.",
    "batteryVoltage": "In quis.",
    "transactionId": "2e740960-4bae-11e9-8561-af645d56312b",
    "timestamp": "2019-03-21T07:51:48.726+00:00"
}
org.accordproject.iot.SingleButtonPress
{
    "$class": "org.accordproject.iot.SingleButtonPress",
    "serialNumber": "Ut officia.",
    "batteryVoltage": "Do voluptate.",
    "transactionId": "2e73e250-4bae-11e9-8561-af645d56312b",
    "timestamp": "2019-03-21T07:51:48.725+00:00"
}
org.accordproject.payment.iot.MonetaryAmountPayment
{
    "$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
    "amount": {
        "$class": "org.accordproject.money.MonetaryAmount",
        "doubleValue": 210.211,
        "currencyCode": "UGX"
    },
    "transactionId": "2e740961-4bae-11e9-8561-af645d56312b",
    "timestamp": "2019-03-21T07:51:48.726+00:00"
}
org.accordproject.signature.ContractSigned
{
    "$class": "org.accordproject.signature.ContractSigned",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#1732",
    "transactionId": "2e73bb40-4bae-11e9-8561-af645d56312b",
    "timestamp": "2019-03-21T07:51:48.724+00:00"
}

Response Types

Type Sample JSON
org.accordproject.cicero.runtime.Response
{
    "$class": "org.accordproject.cicero.runtime.Response",
    "transactionId": "2e743072-4bae-11e9-8561-af645d56312b",
    "timestamp": "2019-03-21T07:51:48.727+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": 150.721,
        "currencyCode": "BSD"
    },
    "description": "Enim dolor nostrud reprehenderit esse.",
    "contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#3104",
    "promisor": "resource:org.accordproject.cicero.contract.AccordParty#8736",
    "promisee": "resource:org.accordproject.cicero.contract.AccordParty#8137",
    "deadline": "2019-03-21T07:51:48.729+00:00",
    "eventId": "2e747e92-4bae-11e9-8561-af645d56312b",
    "timestamp": "2019-03-21T07:51:48.729+00:00"
}