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}} {{currencyCode}} 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.paymentuponiot@0.1.0.TemplateModel",
"buyer": "resource:org.accordproject.party.Party#Dan",
"seller": "resource:org.accordproject.party.Party#Grant",
"amountPerUnit": {
"$class": "org.accordproject.money.MonetaryAmount",
"doubleValue": 10,
"currencyCode": "USD"
},
"paymentCount": 5,
"$identifier": "4fdf51f3-d431-400a-b38b-3e37c83e6cea",
"clauseId": "4fdf51f3-d431-400a-b38b-3e37c83e6cea"
}
namespace org.accordproject.paymentuponiot@0.1.0
import org.accordproject.contract@0.2.0.Clause from https://models.accordproject.org/accordproject/contract@0.2.0.cto
import org.accordproject.runtime@0.2.0.{Request,Response} from https://models.accordproject.org/accordproject/runtime@0.2.0.cto
/**
* Lifecycle status of the contract
*/
enum ContractLifecycleStatus {
o INITIALIZED
o RUNNING
o COMPLETED
}
/**
* Request: contract signed (transitions INITIALIZED -> RUNNING)
*/
transaction ContractSigned extends Request {
o String contractId
}
/**
* Request: single button press — increments counter
*/
transaction SingleButtonPress extends Request {
}
/**
* Request: double button press — decrements counter
*/
transaction DoubleButtonPress extends Request {
}
/**
* Request: long button press — emits payment obligation
*/
transaction LongButtonPress extends Request {
}
/**
* Request: payment received — decrements counter by units paid
*/
transaction PaymentReceived extends Request {
o Double amount
o String currencyCode
}
/**
* Response for counter-related operations
*/
transaction CounterResponse extends Response {
o Double counter
o Double paymentCount
}
/**
* Event emitted when payment is due
*/
event PaymentObligationEvent {
o Double amount
o String currencyCode
o String description
}
/**
* State for the payment upon IoT contract
*/
concept CounterState identified {
o ContractLifecycleStatus status
o Double counter
o Double paymentCount
}
/**
* The template model
*/
@template
asset TemplateModel extends Clause {
o String buyer
o String seller
o Double amountPerUnit
o String currencyCode
o Integer paymentCount
}