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.
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.
Upon long button press, {{buyer}} shall pay to {{seller}} {{amountPerUnit}} for each short button press. A maximum of {{paymentCount}} payments may be made before this contract is COMPLETED.
Note: to undo a short button press the buyer may double-press the button.
{
"$class": "org.accordproject.payment.iot.PaymentUponButtonContract",
"contractId": "1fb876c1-a2b8-4501-9e57-ee7a6a89dcf4",
"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
}
namespace org.accordproject.payment.iot
import org.accordproject.cicero.contract.* from https://models.accordproject.org/cicero/contract.cto
import org.accordproject.cicero.runtime.* from https://models.accordproject.org/cicero/runtime.cto
import org.accordproject.money.MonetaryAmount from https://models.accordproject.org/money.cto
import org.accordproject.payment.PaymentReceived from https://models.accordproject.org/payment/payment.cto
import org.accordproject.signature.ContractSigned from https://models.accordproject.org/signature/signature.cto
import org.accordproject.iot.SingleButtonPress from https://models.accordproject.org/iot/iot.cto
import org.accordproject.iot.DoubleButtonPress from https://models.accordproject.org/iot/iot.cto
import org.accordproject.iot.LongButtonPress from https://models.accordproject.org/iot/iot.cto
asset CounterState extends AccordContractState {
o ContractLifecycleStatus status
o Double counter
o Double paymentCount
}
enum ContractLifecycleStatus {
o INITIALIZED
o RUNNING
o COMPLETED
}
transaction CounterResponse extends Response {
o Double counter
o Double paymentCount
}
transaction MonetaryAmountPayment extends PaymentReceived {
o MonetaryAmount amount
}
/**
* The template model
*/
asset PaymentUponButtonContract extends AccordContract {
o AccordParty buyer
o AccordParty seller
o MonetaryAmount amountPerUnit
o Integer paymentCount
}