DAML Script Library¶
The DAML Script library defines the API used to implement DAML scripts. See DAML Script:: for more information on DAML script.
Module Daml.Script¶
Data Types¶
data Commands a
This is used to build up the commands send as part of
submit
. If you enable theApplicativeDo
extension by adding{-# LANGUAGE ApplicativeDo #-}
at the top of your file, you can usedo
-notation but the individual commands must not depend on each other.instance Functor Commands
instance HasSubmit Script Commands
instance Applicative Commands
instance HasField “commands” (SubmitCmd a) (Commands a)
instance HasField “commands” (SubmitMustFailCmd a) (Commands a)
data ParticipantName
Field Type Description participantName Text instance HasField “participantName” ParticipantName Text
data PartyDetails
The party details returned by the party management service.
Field Type Description party Party Party id displayName Optional Text Optional display name isLocal Bool True if party is hosted by the backing participant. instance Eq PartyDetails
instance Ord PartyDetails
instance Show PartyDetails
instance HasField “continue” (ListKnownPartiesPayload a) ([PartyDetails] -> a)
instance HasField “displayName” PartyDetails (Optional Text)
instance HasField “isLocal” PartyDetails Bool
instance HasField “party” PartyDetails Party
data PartyIdHint
A hint to the backing participant what party id to allocate. Must be a valid PartyIdString (as described in @value.proto@).
Field Type Description partyIdHint Text instance HasField “partyIdHint” PartyIdHint Text
data Script a
This is the type of A DAML script.
Script
is an instance ofAction
, so you can usedo
notation.instance Functor Script
instance CanAbort Script
instance HasSubmit Script Commands
instance HasTime Script
instance Action Script
instance ActionFail Script
instance Applicative Script
instance HasField “runScript” (Script a) (() -> Free ScriptF (a, ()))
Functions¶
- query
: Template t => Party -> Script [(ContractId t, t)]
Query the set of active contracts of the template that are visible to the given party.
- queryContractId
: Template t => Party -> ContractId t -> Script (Optional t)
Query for the contract with the given contract id.
Returns
None
if there is no active contract the party is a stakeholder on. This is semantically equivalent to callingquery
and filtering on the client side.
- setTime
: Time -> Script ()
Set the time via the time service.
This is only supported in static time mode when running over the gRPC API.
Note that the ledger time service does not support going backwards in time. However, you can go back in time in DAML Studio.
- passTime
: RelTime -> Script ()
Advance ledger time by the given interval.
Only supported in static time mode when running over the gRPC API and in DAML Studio. Note that this is not an atomic operation over the gRPC API so no other clients should try to change time while this is running.
Note that the ledger time service does not support going backwards in time. However, you can go back in time in DAML Studio.
- allocateParty
: Text -> Script Party
Allocate a party with the given display name using the party management service.
- allocatePartyWithHint
: Text -> PartyIdHint -> Script Party
Allocate a party with the given display name and id hint using the party management service.
- allocatePartyOn
: Text -> ParticipantName -> Script Party
Allocate a party with the given display name on the specified participant using the party management service.
- allocatePartyWithHintOn
: Text -> PartyIdHint -> ParticipantName -> Script Party
Allocate a party with the given display name and id hint on the specified participant using the party management service.
- listKnownParties
: Script [PartyDetails]
List the parties known to the default participant.
- listKnownPartiesOn
: ParticipantName -> Script [PartyDetails]
List the parties known to the given participant.
- sleep
: RelTime -> Script ()
Sleep for the given duration.
This is primarily useful in tests where you repeatedly call
query
until a certain state is reached.Note that this will sleep for the same duration in both wallcock and static time mode.
- exerciseCmd
: Choice t c r => ContractId t -> c -> Commands r
Exercise a choice on the given contract.
- exerciseByKeyCmd
: (TemplateKey t k, Choice t c r) => k -> c -> Commands r
Exercise a choice on the contract with the given key.
- createAndExerciseCmd
: Choice t c r => t -> c -> Commands r
Create a contract and exercise a choice on it in the same transacton.
- archiveCmd
: Choice t Archive () => ContractId t -> Commands ()
Archive the given contract.
archiveCmd cid
is equivalent toexerciseCmd cid Archive
.