# Create Contracts by JSON API Fail

**URL:** <https://forum.canton.network/t/create-contracts-by-json-api-fail/4544>\
**Category:** App Development\
**Created:** [May 17, 2022, 11:05am UTC](https://forum.canton.network/t/create-contracts-by-json-api-fail/4544 "2022-05-17T11:05:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://forum.canton.network/u/Bernardo)\
**Post date:** [May 17, 2022, 11:05am UTC](https://forum.canton.network/t/create-contracts-by-json-api-fail/4544/1 "2022-05-17T11:05:58Z")

</div>

I am upgrading to version 2.1.1, from 1.18.1,

This is my daml code, that works in version 1.18.1:

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/b/b5aa6fc87d81406ecc923518426eed4556b4ab8f.png)

I use the following commands to initiate canton:

bin/canton -c examples/01-simple-topology/simple-topology.conf  
participant1.domains.connect\_local(mydomain)  
participant2.domains.connect\_local(mydomain)

val alice = participant1.parties.enable(“Alice”)  
mydomain.parties.list(“Alice”)

val bob = participant2.parties.enable(“Bob”)  
mydomain.parties.list(“Bob”)

participants.all.dars.upload(“Project/.daml/dist/Project-0.0.1.dar”)  
participant1.dars.list()  
participant2.dars.list()

Config file:  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/f/f377a993e567a4838c362a03c8449be869a43b20.png)

To initiate JSON API:

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/2/242f9ef48487117ea2f55adbbbbd2900d836517e.png)

My Java code, working on daml 1.18.1:

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/d/dfb689594beece8e62367eb20243d430cdea7fe7.png)  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/9/915bead9f41d108a0c9d6648b8ad7aebe32e1c1e.png)

My wireshark LOG:

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/7/7e521ff945eca8ad09d7be75a7191bd7b4fb751c.png)

I can create contracts with JSON API in version 1.18.1, but with CANTON and daml 2.1.1 i cannot, any clue?

Thanks

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [May 17, 2022, 11:14am UTC](https://forum.canton.network/t/create-contracts-by-json-api-fail/4544/2 "2022-05-17T11:14:13Z")

</div>

Notice that you are using hard-coded party identifiers. In Daml 2 we improved party identifiers to make sure the transition from prototype to production in a decentralized environment is smoother. As such, party identifiers are now no longer tied to party ID hints (which was an artifact of the old sandbox, not part of the actual Ledger API). You can read more on the impact of this on the development workflow [here](https://blog.digitalasset.com/developers/parties-users-daml-2).

---

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://forum.canton.network/u/Bernardo)\
**Post date:** [May 17, 2022, 3:59pm UTC](https://forum.canton.network/t/create-contracts-by-json-api-fail/4544/3 "2022-05-17T15:59:51Z")

</div>

I have read the post, but how can i allocate a party besides daml.yaml?

---

<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:** [May 17, 2022, 4:50pm UTC](https://forum.canton.network/t/create-contracts-by-json-api-fail/4544/4 "2022-05-17T16:50:11Z")

</div>

For most applications, my recommendation is to allocate parties via Daml Script’s `allocateParty`/`allocatePartyWithHint`. You can point to a specific Daml script via the `init-script` field in your `daml.yaml` in which case it will be picked up automatically when you run `daml start`. Take a look at the [Daml Script documentation](https://docs.daml.com/daml-script/index.html) for more details.

---

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://forum.canton.network/u/Bernardo)\
**Post date:** [May 18, 2022, 11:24am UTC](https://forum.canton.network/t/create-contracts-by-json-api-fail/4544/5 "2022-05-18T11:24:19Z")

</div>

Hello,

I created my script:

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/3/39a4cee75fea5bf8857412cf6ab30b7439d46dc8.png)

My yaml file:  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/c/c705572f31e8411688a1e02a565be906e633f6f5.png)

Still, when i run daml start, i cant create contracts by Navigator or JSON API, what is wrong here?

Besides i want to use 2 participants and 1 domain so the daml start command does not aply here,

Thank you

---

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://forum.canton.network/u/Bernardo)\
**Post date:** [May 20, 2022, 9:19am UTC](https://forum.canton.network/t/create-contracts-by-json-api-fail/4544/6 "2022-05-20T09:19:29Z")

</div>

This is my code:  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/4/4095b80a1649cf3c750fe7b15a19c327a4dc87b2.png)

 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/4/44c65a24eefc98db0b1cae6ad9fba0dffbb7be51.png)

Yaml file:  
 ![image](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/e/ebc0a8f22e95cc166300ae4526ef8b70c6ceb5fd.png)
