# allocatePartyWithHintOn and listKnownPartiesOn behaving unexpectedly

**URL:** <https://forum.canton.network/t/allocatepartywithhinton-and-listknownpartieson-behaving-unexpectedly/5187>\
**Category:** App Development\
**Tags:** daml-script, canton\
**Created:** [September 6, 2022, 2:04pm UTC](https://forum.canton.network/t/allocatepartywithhinton-and-listknownpartieson-behaving-unexpectedly/5187 "2022-09-06T14:04:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jonas](https://forum.canton.network/u/jonas)\
**Post date:** [September 6, 2022, 2:04pm UTC](https://forum.canton.network/t/allocatepartywithhinton-and-listknownpartieson-behaving-unexpectedly/5187/1 "2022-09-06T14:04:01Z")

</div>

Hey all. I was trying to use Daml script to simulate a multi-party scenario but I am completely unable to make `allocatePartyWithHintOn` allocate parties on specific participants.

In my Canton setup I have two participants:

- participant1, which connects to domain1
- participant2, which connects to domain2

I exported this to `participants.json` (with `participant1` as the default participant) and I pass that to `daml script`.

In the script I have the following code:

```nohighlight
bob <- allocatePartyWithHintOn "Bob" (PartyIdHint "Bob") (ParticipantName "participant1")
bobette <- allocatePartyWithHintOn "Bobette" (PartyIdHint "Bobette") (ParticipantName "participant2")

```

The issue I have is that it seems to be ignoring the participant name. Instead it always seems to do everything on the default participant.

In Canton, when I enter `participant1.parties.list()` I see both Bob and Bobette (and participant1). If I enter `participant2.parties.list()` I see neither (I only see participant2).

Interestingly, when i try to use `listKnownPartiesOn` in the Daml script then I see Bob and Bobette and participant1 regardless of what I enter for participant name.

Finally I want to point out that `allocatePartyWithHintOn` and `listKnownPartiesOn` behave this way even when I enter a participant name that doesn’t exist at all.

So what gives? Why might this not be working as I would expect it to?

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [September 6, 2022, 2:06pm UTC](https://forum.canton.network/t/allocatepartywithhinton-and-listknownpartieson-behaving-unexpectedly/5187/2 "2022-09-06T14:06:31Z")

</div>

Can you share your `participants.json`?

---

<div class="post-metadata">

**Author:** ![jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jonas](https://forum.canton.network/u/jonas)\
**Post date:** [September 6, 2022, 2:11pm UTC](https://forum.canton.network/t/allocatepartywithhinton-and-listknownpartieson-behaving-unexpectedly/5187/3 "2022-09-06T14:11:42Z")

</div>

Sure thing. I added some other files also in case they’re useful.

participants.json:

```json
{
  "default_participant" : {
    "host" : "127.0.0.1",
    "port" : 5021
  },
  "participants" : {
    "participant1::12203fe150cc7164836135fa48031cca0ce396e8a2fbc6b7eaed564bd30cfeb13a62" : {
      "host" : "127.0.0.1",
      "port" : 5011
    },
    "participant2::12200c67a3d938e73431c240e07490536eefad6610b2d6cd14fb7b4b08cdaa37bf4f" : {
      "host" : "127.0.0.1",
      "port" : 5021
    }
  },
  "party_participants" : {
    "participant1::12203fe150cc7164836135fa48031cca0ce396e8a2fbc6b7eaed564bd30cfeb13a62" : "participant1::12203fe150cc7164836135fa48031cca0ce396e8a2fbc6b7eaed564bd30cfeb13a62",
    "participant2::12200c67a3d938e73431c240e07490536eefad6610b2d6cd14fb7b4b08cdaa37bf4f" : "participant2::12200c67a3d938e73431c240e07490536eefad6610b2d6cd14fb7b4b08cdaa37bf4f"
  }
}

```

canton.conf:

```nohighlight
canton {
  participants {
    participant1 {
      storage.type = memory
      admin-api.port = 5012
      ledger-api.port = 5011
    }
    participant2 {
      storage.type = memory
      admin-api.port = 5022
      ledger-api.port = 5021
    }
  }
  domains {
    domain1 {
      storage.type = memory
      public-api.port = 5018
      admin-api.port = 5019
    }
    domain2 {
      storage.type = memory
      public-api.port = 5028
      admin-api.port = 5029
    }
  }
  // enable ledger_api commands for our getting started guide
  features.enable-testing-commands = yes
}

```

setup.canton:

```scala
nodes.local start

println("participant1 connects only to domain1")
participant1.domains.connect_local(domain1)

println("participant2 connects only to domain2")
participant2.domains.connect_local(domain2)

participants.all.dars.upload("generated/script.dar")

val participantConfigFile = "./generated/participants.json"
println(s"📝 ${participantConfigFile}")
utils.generate_daml_script_participants_conf(Some(participantConfigFile), Some(participant2))

```

Script.daml:

```nohighlight
module Script where

import Daml.Script

import DA.Foldable (forA_)

go : Script ()
go = do
  bob <- allocatePartyWithHintOn "Bob" (PartyIdHint "Bob") (ParticipantName "participant1")
  bobette <- allocatePartyWithHintOn "Bobette" (PartyIdHint "Bobette") (ParticipantName "participant2")

  forA_ ["participant1", "participant2", "doesnotexist"] $ \name -> do
    debugRaw $ "Parties on " <> name <> ":"
    listKnownPartiesOn (ParticipantName name) >>= debug

```

(Actually I just noticed that this has one change compared to my post. Here participant2 is the default participant, and so that’s where the parties show up.)

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [September 6, 2022, 2:17pm UTC](https://forum.canton.network/t/allocatepartywithhinton-and-listknownpartieson-behaving-unexpectedly/5187/4 "2022-09-06T14:17:35Z")

</div>

The participant name you use in Daml must match the key of the corresponding JSON object. You have `particpant1` in your Daml code but then `participant1::122…` in your JSON file. If you get the two in sync, it should work properly.

Note that `default_participant` is optional. If you remove that, you should get an error if there is a mismatch rather than a fallback to `default_participant`.

---

<div class="post-metadata">

**Author:** ![jonas](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jonas](https://forum.canton.network/u/jonas)\
**Post date:** [September 6, 2022, 2:19pm UTC](https://forum.canton.network/t/allocatepartywithhinton-and-listknownpartieson-behaving-unexpectedly/5187/5 "2022-09-06T14:19:41Z")

</div>

@cocreature Thanks. That makes perfect sense. It’s really confusing, though, that it silently falls back to the default participant.
