- Overview
- Setup
- Tutorials
- How Tos
- Reference
Utility.Commercials.V0.Model.CommercialAgreement¶
Templates used for payment of fees for using the Utility.
Templates¶
template CommercialAgreement
A commercial agreement that describes the fees that the user will pay for using the Utility.
Signatory: operator, user
Field
Type
Description
operator
App operator.
user
App user.
feeReceiver
The party that will receive the fee for using the Utility services.
lockedAmuletCids
Coins locked to the operator which are used to pay fees.
currentLockedAmuletAmountCc
Current amount of locked CC held as part of the commercial agreement.
utilityFees
The fee that the user will pay for using the Utility services.
dso
Reference to the DSO party (Decentralized Synchronizer Operations).
baseFeeBillingState
State of the base fee billing process. This field is available starting from version
0.1.0of this package.credentialFeeBillingState
State of the credential fee billing process. This field is available starting from version
0.2.0of this package.accruedFeesCc
Fees accrued (but not yet paid) as part of the commercial agreement. This field is available starting from version
0.3.0of this package.rewardReceiver
The party that will receive the rewards from the Utility service fees. This field is available starting from version
0.3.0of this package.
Choice Archive
Controller: operator, user
Returns: ()
(no fields)
Choice CommercialAgreement\_Bill
Trigger a payment of the agreed fee for performing a billing on behalf of the user. Deprecated, use CommercialAgreement_BillCredentialFeeMulti instead. This choice is disabled as of version
0.2.1of this package.Controller: operator
Returns: CommercialAgreement\_Bill\_Result
Field
Type
Description
transferContext
Context for CC transfers.
transferPreapprovalCid
Preapproval from a party to receive the fee. If the fee payment should be a featured transfer, ensure that the TransferPreapproval contains a featuredAppRight.
paymentTransferContext
Context for preapproved CC transfers.
Choice CommercialAgreement\_BillBaseFee
Trigger a payment of the agreed base fee. This choice is available starting from version
0.1.0of this package.Controller: operator
Returns: CommercialAgreement\_BillBaseFee\_Result
Field
Type
Description
transferContext
Context for CC transfers.
transferPreapprovalCid
Preapproval from a party to receive the fee. If the fee payment should be a featured transfer, ensure that the TransferPreapproval contains a featuredAppRight.
paymentTransferContext
Context for preapproved CC transfers.
Choice CommercialAgreement\_BillCredentialFeeMulti
Trigger payments of the agreed fee for performing multiple credential billings on behalf of the user. This choice is available starting from version
0.2.0of this package.Controller: operator
Returns: CommercialAgreement\_BillCredentialFeeMulti\_Result
Field
Type
Description
transferContext
Context for CC transfers.
transferPreapprovalCid
Preapproval from a party to receive the fee. If the fee payment should be a featured transfer, ensure that the TransferPreapproval contains a featuredAppRight.
paymentTransferContext
Context for preapproved CC transfers.
numberOfBillings
Number of credential billings performed on behalf of the user.
currentLedgerOffset
The current ledger offset, which is stored as reference data if the payment succeeds.
currentMigrationId
The migration id is used to support Hard Domain Migration for this commercial agreement. This field is available starting from version
0.3.0of this package.
Choice CommercialAgreement\_BillCredentialFeeMultiUnfeatured
Trigger payments of the agreed fee for performing multiple credential billings on behalf of the user. This choice is available starting from version
0.3.0of this package.Controller: operator
Returns: CommercialAgreement\_BillCredentialFeeMultiUnfeatured\_Result
Field
Type
Description
transferContext
Context for CC transfers.
transferPreapprovalCid
Preapproval from a party to receive the fee. If the fee payment should be a featured transfer, ensure that the TransferPreapproval contains a featuredAppRight.
numberOfBillings
Number of credential billings performed on behalf of the user.
currentLedgerOffset
The current ledger offset, which is stored as reference data if the payment succeeds.
payoutThresholdCc
If the accrued fees exceed this threshold, they will be paid out as part of this billing operation.
currentMigrationId
The migration id is used to support Hard Domain Migration for this commercial agreement. This field is available starting from version
0.3.0of this package.
Choice CommercialAgreement\_FlushExpiredDeposit
Flush the deposit of a commercial agreement where the locked deposit has expired. This is useful to recover from missing/expired locked deposits. This choice was added as of version
0.4.0of this package.Controller: actor
Returns: CommercialAgreement\_FlushExpiredDeposit\_Result
Field
Type
Description
actor
The party performing the flush (either the user or the operator).
Choice CommercialAgreement\_LockCoin
Lock coins (for future fee payments) to the operator. This increases (or decreases) the deposit to reach the specified target amount.
Controller: user
Returns: CommercialAgreement\_LockCoin\_Result
Field
Type
Description
targetAmount
Lock coins so that the deposit reaches this target amount of totally locked coin.
coinCids
Coins to lock.
transferContext
Context for CC transfers.
Choice CommercialAgreement\_Modify
Modify the commercial agreement. It keeps the operator, user, dso and deposit unchanged.
Controller: operator
Returns: CommercialAgreement\_Modify\_Result
Field
Type
Description
feeReceiver
The party that will receive the fee for using the Utility services.
utilityFees
The fee that the user will pay for using the Utility services.
rewardReceiver
The party that will receive the rewards from the Utility service fees. This field is available starting from version
0.3.0of this package.
Choice CommercialAgreement\_Revoke
Revoke the commercial agreement (and unlock the deposit).
Controller: actor
Returns: CommercialAgreement\_Revoke\_Result
Field
Type
Description
transferContext
Reference data for unlocking the deposit.
actor
The party that is performing the revocation (either the user or the operator).
transferPreapprovalCid
Preapproval from a party to receive the fee. If the fee payment should be a featured transfer, ensure that the TransferPreapproval is created by a featured provider. This field is available starting from version
0.3.0of this package.
Choice CommercialAgreement\_SetDefaultCredentialFeeBillingState
Set a default credential fee billing state. This is useful for older versions of (or newly created) commercial agreements, which do not yet have a billing state. This choice is available starting from version
0.2.0of this package.Controller: operator
Returns: CommercialAgreement\_SetDefaultCredentialFeeBillingState\_Result
Field
Type
Description
currentLedgerOffset
The current ledger offset.
currentMigrationId
The migration id is used to support Hard Domain Migration for this commercial agreement. This field is available starting from version
0.3.0of this package.
Data Types¶
data CommercialAgreement\_BillBaseFee\_Result
Result of
CommercialAgreement_BillBaseFee.
CommercialAgreement\_BillBaseFee\_Result
Field
Type
Description
commercialAgreementCid
The updated commercial agreement contract id after billing the base fee.
data CommercialAgreement\_BillCredentialFeeMultiUnfeatured\_Result
Result of
CommercialAgreement_BillCredentialFeeMultiUnfeatured.
CommercialAgreement\_BillCredentialFeeMultiUnfeatured\_Result
Field
Type
Description
commercialAgreementCid
The updated commercial agreement contract id after billing multiple credential fees.
credentialFeeBillingState
The updated credential fee billing state.
data CommercialAgreement\_BillCredentialFeeMulti\_Result
Result of
CommercialAgreement_BillCredentialFeeMulti.
CommercialAgreement\_BillCredentialFeeMulti\_Result
Field
Type
Description
commercialAgreementCid
The updated commercial agreement contract id after billing multiple credential fees.
credentialFeeBillingState
The updated credential fee billing state.
data CommercialAgreement\_Bill\_Result
Result of
CommercialAgreement_Bill.
CommercialAgreement\_Bill\_Result
Field
Type
Description
commercialAgreementCid
The updated commercial agreement contract id after billing a credential fee.
data CommercialAgreement\_FlushExpiredDeposit\_Result
Result of
CommercialAgreement_FlushExpiredDeposit.
CommercialAgreement\_FlushExpiredDeposit\_Result
Field
Type
Description
commercialAgreementCid
The updated commercial agreement contract id after flushing the expired deposit.
data CommercialAgreement\_LockCoin\_Result
Result of
CommercialAgreement_LockCoin.
CommercialAgreement\_LockCoin\_Result
Field
Type
Description
commercialAgreementCid
The updated commercial agreement contract id after locking coin.
data CommercialAgreement\_Modify\_Result
Result of
CommercialAgreement_Modify.
CommercialAgreement\_Modify\_Result
Field
Type
Description
commercialAgreementCid
The modified commercial agreement contract id.
data CommercialAgreement\_Revoke\_Result
Result of
CommercialAgreement_Revoke.
CommercialAgreement\_Revoke\_Result
Field
Type
Description
unlockedDeposit
The unlocked deposit.
data CommercialAgreement\_SetDefaultCredentialFeeBillingState\_Result
Result of
CommercialAgreement_SetDefaultCredentialFeeBillingState.
CommercialAgreement\_SetDefaultCredentialFeeBillingState\_Result
Field
Type
Description
commercialAgreementCid
The updated commercial agreement contract id.
credentialFeeBillingState
The updated credential fee billing state.
Functions¶
: AppTransferContext -> ContractId LockedAmulet -> Update (ContractId Amulet)
Unlock an existing deposit and return the unlocked coins.
: AppTransferContext -> ContractId LockedAmulet -> Update TransferInput
Unlock an existing deposit and return the coin as InputAmulet for a transfer.
: BillingContext -> Time -> FixedFee -> BillingState -> BillingCycleParams
Compute the billing parameters for the next billing cycle.
prepareAndValidatePreapprovedTransfer
: CommercialAgreement -> AppTransferContext -> ContractId TransferPreapproval -> Update [ContractId Amulet]
Unlock the deposit and validate the preapproval.
: [ContractId Amulet] -> Decimal -> CommercialAgreement -> Time -> BillingContext -> Update (ContractId LockedAmulet, Decimal)
Lock the remaining coin after the transfer.
: CommercialAgreement -> AppTransferContext -> ContractId TransferPreapproval -> PaymentTransferContext -> Decimal -> Time -> BillingContext -> Update ([ContractId LockedAmulet], Decimal)
Pay a commercial agreement fee using the locked deposit.
: Decimal
Number of minutes in a day.
: RatePerDay -> RelTime -> Decimal
Calculate the charge for a given period based on a
RatePerDay. This operation might introduce rounding errors.
: Party -> ContractId Amulet -> Update Decimal
Verify the DSO party of a given Amulet and return the amount.
: Party -> [ContractId Amulet] -> Update Decimal
Verify a list of Amulets and return the total amount.
fetchAndValidateBillingContext
: Party -> Party -> AppTransferContext -> Update BillingContext
Fetch the billing context components from the ledger and validate them.