When I deployed the wallet app on daml hub , I could see there are 3 parties by default present. I need to know , what is purpose of user admin serving there . and can we allow user Admin to see the contracts being created or archived . how to achieve it ?
One of the three parties is just a normal party created automatically for your Daml Hub account, but the other two do have special significance.
The UserAdmin
and Public
party are what we refer to as “default” or “well known” parties because users of your application (or your UI) can use the following endpoint to request the party idenfitiers of those parties: https://hub.daml.com/docs/api#operation/getDefaultParties.
The Public
party and UserAdmin
party are different in that the Public
party also has an endpoint for retrieving a Read Only token that can be used to query all contracts that the Public
party has visibility on: https://hub.daml.com/docs/api#operation/getPublicPartyToken. The UserAdmin
’s read/write token is only available to the ledger owner.
In terms of how and why you might use those, for UserAdmin
, having the UserAdmin
party as the “operator” or one of the signatories on contracts can be helpful since you can control who is able to sign up for contracts, and also give a user a way to look them up. For example if you had this User
contract:
template User
with
operator : Party
owner : Party
where
signatory operator, owner
key (operator, owner) : (Party, Party)
maintainer key._1
Not only can any party not just create a User
contract without you authorizing it (you would need some sort of request/accept flow), you could use a lookup or exercise by key in the UI since the end user has knowledge of who the operator
party is.
To answer your other question regarding the UserAdmin
, if you want your UserAdmin
party to be able to see contracts (or use their token to see create/archive events using the GRPC transaction stream), they will need to explicitly be a signatory
or observer
on the contracts.
With the public party, you might put it on an observer of an AssetType
:
template AssetType
with
operator : Party
public : Party
name : Text
where
signatory operator
observer public
And then use the Public party token endpoint in your UI to query for all asset types on the ledger.
Let me know if you have any more questions!
@Virendra_Solanke
To add to the reply by @alex.graham, since you mentioned the Wallet Sample App, in this app we don’t use Public party. But we do use UserAdmin. In the Wallet Sample App UserAdmin party is the issuer of the ET (Example Token) coin. It is the party that, as a user of the app, you interact with when for example you utilize “Use Default Party” in the Swap workflow in the app GUI. It is the party that sends you the invite to create an account for ET coin when you login to the app for the first time.
Daml is the smart contract language used to create multi-party applications. Wallet Sample App is a learning tool for new Daml developers that illustrates the implementation of some common workflows in a multi-party application. We realized that most Daml learners won’t have any other user to play with when they look at the Wallet Sample App. To provide a level of interactivity for solo users we created a bot that can act as a counterparty for say a swap transaction and automatically accept a swap proposal that you send. This bot is implemented using Daml Triggers, which are run under the authority of UserAdmin party.
Thanks @alex.graham . Sure I will let you know if I stuck somewhere
Thanks @a_putkov , Its really helpful.