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": "09fd0c43-c210-4a80-921b-6861e2b766d8",
"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": 238.335,
"paymentCount": 3.913,
"stateId": "ccda62b3-575d-11e9-9ffa-db0629e5d319"
}
|
Request Types
Type |
Sample JSON |
org.accordproject.iot.DoubleButtonPress |
{
"$class": "org.accordproject.iot.DoubleButtonPress",
"serialNumber": "Qui culpa minim.",
"batteryVoltage": "Occaecat labore do officia minim.",
"transactionId": "ccda1491-575d-11e9-9ffa-db0629e5d319",
"timestamp": "2019-04-05T00:46:39.193-04:00"
}
|
org.accordproject.iot.LongButtonPress |
{
"$class": "org.accordproject.iot.LongButtonPress",
"serialNumber": "Sit.",
"batteryVoltage": "Ut sunt duis.",
"transactionId": "ccda1492-575d-11e9-9ffa-db0629e5d319",
"timestamp": "2019-04-05T00:46:39.193-04:00"
}
|
org.accordproject.iot.SingleButtonPress |
{
"$class": "org.accordproject.iot.SingleButtonPress",
"serialNumber": "Adipisicing pariatur.",
"batteryVoltage": "Ullamco.",
"transactionId": "ccda1490-575d-11e9-9ffa-db0629e5d319",
"timestamp": "2019-04-05T00:46:39.193-04:00"
}
|
org.accordproject.payment.iot.MonetaryAmountPayment |
{
"$class": "org.accordproject.payment.iot.MonetaryAmountPayment",
"amount": {
"$class": "org.accordproject.money.MonetaryAmount",
"doubleValue": 112.98,
"currencyCode": "PKR"
},
"transactionId": "ccda1493-575d-11e9-9ffa-db0629e5d319",
"timestamp": "2019-04-05T00:46:39.193-04:00"
}
|
org.accordproject.signature.ContractSigned |
{
"$class": "org.accordproject.signature.ContractSigned",
"contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#5222",
"transactionId": "ccd9ed80-575d-11e9-9ffa-db0629e5d319",
"timestamp": "2019-04-05T00:46:39.192-04:00"
}
|
Response Types
Type |
Sample JSON |
org.accordproject.cicero.runtime.Response |
{
"$class": "org.accordproject.cicero.runtime.Response",
"transactionId": "ccda3ba4-575d-11e9-9ffa-db0629e5d319",
"timestamp": "2019-04-05T00:46:39.194-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": 146.796,
"currencyCode": "UGX"
},
"description": "Duis sunt ullamco.",
"contract": "resource:org.accordproject.payment.iot.PaymentUponButtonContract#8397",
"promisor": "resource:org.accordproject.cicero.contract.AccordParty#0882",
"promisee": "resource:org.accordproject.cicero.contract.AccordParty#6074",
"deadline": "2019-04-05T00:46:39.195-04:00",
"eventId": "ccda62b4-575d-11e9-9ffa-db0629e5d319",
"timestamp": "2019-04-05T00:46:39.195-04:00"
}
|