Skip to content
CCPEDIAby Unity Nodes
App Development

Canton console command for creating a user in v2.0

2 posts429 views6 likesLast activity Mar 2022

  1. kctamOP 1

    Hi team,

    Sorry for my poor skill on the canton console command. From the doc I see this is how to create a user pointing to a party ID, using a command ledger_api.users.create:

    ledger_api.users.create (Testing)
    Summary: Create a user with the given id
    Arguments:
    id: String
    actAs: Set[com.digitalasset.canton.LfPartyId]
    primaryParty: Option[com.digitalasset.canton.LfPartyId]
    readAs: Set[com.digitalasset.canton.LfPartyId]
    participantAdmin: Boolean
    Return type:
    com.digitalasset.canton.admin.api.client.data.LedgerApiUser
    

    If I am in the Canton console and I have already created a party Alice::namespace, what is the right command I should type in the console such that i can create a user “alice” and set Alice::namespace as the primary party ID? I got stuck as there are some required arguments I donno how to input, such as Set, Option, etc.

    Thanks for your kind help.

    Best regards,
    kc

  2. Arne_Gebert 5

    Hi @kctam
    Here is an example for making party alice the primary party for user alice:

    val alice = participant1.parties.enable("alice")
    participant1.ledger_api.users.create(
      id = "alice",
      actAs = Set(alice.toLf),
      primaryParty = Some(alice.toLf),
      readAs = Set(alice.toLf),
    )
    
    

    You can check via

    participant1.ledger_api.users.list().users.map(_.id)
    

    that it worked (you should see “alice” in the output).

    Hope this helps!
    Best Arne