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": "89706f8c-3745-4e23-adfd-f29153372af8",
"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": 200.502,
"paymentCount": 43.474,
"stateId": "7c175250-9cce-11e9-9a6f-d5f6456622aa"
}
|
Request Types
Type |
Sample JSON |
org.accordproject.iot.DoubleButtonPress |
{
"$class": "org.accordproject.iot.DoubleButtonPress",
"serialNumber": "Qui laborum veniam amet culpa.",
"batteryVoltage": "Veniam qui aute dolore.",
"transactionId": "7c16dd20-9cce-11e9-9a6f-d5f6456622aa",
"timestamp": "2019-07-02T09:37:07.058-04:00"
}
|
org.accordproject.iot.LongButtonPress |
{
"$class": "org.accordproject.iot.LongButtonPress",
"serialNumber": "Lorem exercitation.",
"batteryVoltage": "Ex sint adipisicing laborum velit.",
"transactionId": "7c16dd21-9cce-11e9-9a6f-d5f6456622aa",
"timestamp": "2019-07-02T09:37:07.058-04:00"
}
|
org.accordproject.iot.SingleButtonPress |
{
"$class": "org.accordproject.iot.SingleButtonPress",
"serialNumber": "Ut velit.",
"batteryVoltage": "Eu ut.",
"transactionId": "7c16b611-9cce-11e9-9a6f-d5f6456622aa",
"timestamp": "2019-07-02T09:37:07.057-04:00"
}
|
org.accordproject.payment.iot.MonetaryAmountPayment |
{
"$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
"amount": {
"$class": "org.accordproject.money.MonetaryAmount",
"doubleValue": 170.466,
"currencyCode": "YER"
},
"transactionId": "7c16dd22-9cce-11e9-9a6f-d5f6456622aa",
"timestamp": "2019-07-02T09:37:07.058-04:00"
}
|
org.accordproject.signature.ContractSigned |
{
"$class": "org.accordproject.signature.ContractSigned",
"contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#9955",
"transactionId": "7c16b610-9cce-11e9-9a6f-d5f6456622aa",
"timestamp": "2019-07-02T09:37:07.057-04:00"
}
|
Response Types
Type |
Sample JSON |
org.accordproject.cicero.runtime.Response |
{
"$class": "org.accordproject.cicero.runtime.Response",
"transactionId": "7c170434-9cce-11e9-9a6f-d5f6456622aa",
"timestamp": "2019-07-02T09:37:07.059-04: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": 141.616,
"currencyCode": "TWD"
},
"description": "Quis est amet occaecat proident.",
"contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#5142",
"promisor": "resource:org.accordproject.cicero.contract.AccordParty#8659",
"promisee": "resource:org.accordproject.cicero.contract.AccordParty#1416",
"deadline": "2019-07-02T09:37:07.062-04:00",
"eventId": "7c177960-9cce-11e9-9a6f-d5f6456622aa",
"timestamp": "2019-07-02T09:37:07.062-04:00"
}
|