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

Party

App operator.

user

Party

App user.

feeReceiver

Party

The party that will receive the fee for using the Utility services.

lockedAmuletCids

[ContractId LockedAmulet]

Coins locked to the operator which are used to pay fees.

currentLockedAmuletAmountCc

Decimal

Current amount of locked CC held as part of the commercial agreement.

utilityFees

UtilityFees

The fee that the user will pay for using the Utility services.

dso

Party

Reference to the DSO party (Decentralized Synchronizer Operations).

baseFeeBillingState

Optional BillingState

State of the base fee billing process. This field is available starting from version 0.1.0 of this package.

credentialFeeBillingState

Optional EventBillingState

State of the credential fee billing process. This field is available starting from version 0.2.0 of this package.

Data Types

data CommercialAgreement_BillBaseFee_Result

Result of CommercialAgreement_BillBaseFee.

CommercialAgreement_BillBaseFee_Result

Field

Type

Description

commercialAgreementCid

ContractId CommercialAgreement

The updated commercial agreement contract id after billing the base fee.

data CommercialAgreement_BillCredentialFeeMulti_Result

Result of CommercialAgreement_BillCredentialFeeMulti.

CommercialAgreement_BillCredentialFeeMulti_Result

Field

Type

Description

commercialAgreementCid

ContractId CommercialAgreement

The updated commercial agreement contract id after billing multiple credential fees.

credentialFeeBillingState

EventBillingState

The updated credential fee billing state.

data CommercialAgreement_Bill_Result

Result of CommercialAgreement_Bill.

CommercialAgreement_Bill_Result

Field

Type

Description

commercialAgreementCid

ContractId CommercialAgreement

The updated commercial agreement contract id after billing a credential fee.

data CommercialAgreement_LockCoin_Result

Result of CommercialAgreement_LockCoin.

CommercialAgreement_LockCoin_Result

Field

Type

Description

commercialAgreementCid

ContractId CommercialAgreement

The updated commercial agreement contract id after locking coin.

data CommercialAgreement_Modify_Result

Result of CommercialAgreement_Modify.

CommercialAgreement_Modify_Result

Field

Type

Description

commercialAgreementCid

ContractId CommercialAgreement

The modified commercial agreement contract id.

data CommercialAgreement_Revoke_Result

Result of CommercialAgreement_Revoke.

CommercialAgreement_Revoke_Result

Field

Type

Description

unlockedDeposit

[ContractId Amulet]

The unlocked deposit.

data CommercialAgreement_SetDefaultCredentialFeeBillingState_Result

Result of CommercialAgreement_SetDefaultCredentialFeeBillingState.

CommercialAgreement_SetDefaultCredentialFeeBillingState_Result

Field

Type

Description

commercialAgreementCid

ContractId CommercialAgreement

The updated commercial agreement contract id.

credentialFeeBillingState

EventBillingState

The updated credential fee billing state.

Functions

unlockCoins

: AppTransferContext -> ContractId LockedAmulet -> Update (ContractId Amulet)

Unlock an existing deposit and return the unlocked coins.

unlockDeposit

: AppTransferContext -> ContractId LockedAmulet -> Update TransferInput

Unlock an existing deposit and return the coin as InputAmulet for a transfer.

computeBillingCycleParams

: 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.

lockRemainingCoin

: [ContractId Amulet] -> Decimal -> CommercialAgreement -> Time -> BillingContext -> Update (ContractId LockedAmulet, Decimal)

Lock the remaining coin after the transfer.

payFee

: CommercialAgreement -> AppTransferContext -> ContractId TransferPreapproval -> PaymentTransferContext -> Decimal -> Time -> BillingContext -> Update ([ContractId LockedAmulet], Decimal)

Pay a commercial agreement fee using the locked deposit.

minutesToRelTime

: Int -> RelTime

Convert a number of minutes to a RelTime.

relTimeToMicros

: RelTime -> Decimal

Convert a RelTime to a number of microseconds expressed as Decimal.

relTimeToMinutes

: RelTime -> Decimal

Convert a RelTime to minutes. The time intervals dt we use are typically an integer multiple of minutes, so we can expect this calculation to be exact.

minutesPerDay

: Decimal

Number of minutes in a day.

chargeRatePerDay

: RatePerDay -> RelTime -> Decimal

Calculate the charge for a given period based on a RatePerDay. This operation might introduce rounding errors.

verifyAmulet

: Party -> ContractId Amulet -> Update Decimal

Verify the DSO party of a given Amulet and return the amount.

verifyAmulets

: 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.