This is a payment contract that pays out a fixed amount each time a button is pressed.
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
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.
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": "d2b2b21d-ebe6-4e1d-aa70-9811558d150b",
"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": "RUNNING",
"counter": 3.97,
"paymentCount": 245.954,
"stateId": "ee382f22-152a-11e9-8d02-47431788edc9"
}
|
Request Types
Type |
Sample JSON |
org.accordproject.cicero.runtime.Request |
{
"$class": "org.accordproject.cicero.runtime.Request",
"transactionId": "ee3744c0-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.092Z"
}
|
org.accordproject.iot.DoubleButtonPress |
{
"$class": "org.accordproject.iot.DoubleButtonPress",
"serialNumber": "Quis ea non elit adipisicing.",
"batteryVoltage": "Reprehenderit elit.",
"transactionId": "ee37b9f1-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.095Z"
}
|
org.accordproject.iot.LongButtonPress |
{
"$class": "org.accordproject.iot.LongButtonPress",
"serialNumber": "Aute ex tempor eiusmod Lorem.",
"batteryVoltage": "Nulla enim.",
"transactionId": "ee37b9f2-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.095Z"
}
|
org.accordproject.iot.SingleButtonPress |
{
"$class": "org.accordproject.iot.SingleButtonPress",
"serialNumber": "Ea.",
"batteryVoltage": "Cupidatat est sint nisi culpa.",
"transactionId": "ee37b9f0-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.095Z"
}
|
org.accordproject.payment.iot.MonetaryAmountPayment |
{
"$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
"amount": {
"$class": "org.accordproject.money.MonetaryAmount",
"doubleValue": 177.357,
"currencyCode": "BMD"
},
"transactionId": "ee37b9f3-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.095Z"
}
|
org.accordproject.signature.ContractSigned |
{
"$class": "org.accordproject.signature.ContractSigned",
"contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#3172",
"transactionId": "ee3744c1-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.092Z"
}
|
Response Types
Type |
Sample JSON |
org.accordproject.cicero.runtime.Response |
{
"$class": "org.accordproject.cicero.runtime.Response",
"transactionId": "ee380810-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.097Z"
}
|
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": 82.658,
"currencyCode": "KPW"
},
"description": "Nulla.",
"contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#5326",
"promisor": "resource:org.accordproject.cicero.contract.AccordParty#9685",
"promisee": "resource:org.accordproject.cicero.contract.AccordParty#5506",
"deadline": "2019-01-10T22:56:14.098Z",
"eventId": "ee382f23-152a-11e9-8d02-47431788edc9",
"timestamp": "2019-01-10T22:56:14.098Z"
}
|