Using JSON API with CANTON

I updated the domain conf file, and added both participants:

canton {
domains {
mydomain {
  storage.type = memory
  admin-api {
    port = 10017
    address = 192.168.61.129 // is the default value if omitted
  }
  public-api {
    port = 10018
    address = 192.168.61.129 // is the default value if omitted
  }
 }
}

remote-participants {
 participant1 {
  admin-api {
    port = 5012
    address = 192.168.61.128
  }
  ledger-api {
    port = 5011
    address = 192.168.61.128
  }
 }
}

remote-participants {
 participant2 {
  admin-api {
    port = 5012
    address = 192.168.61.130
  }
  ledger-api {
    port = 5011
    address = 192.168.61.130
   }
  }
 }
}

This is why now i am able to upload the dar and it is visible to participant1 and 2

I just use the daml start --script-option --output-file=parties.json to get the Party ids, in order to create contracts with json api. I need the Party id for alice and bob that are specified in that file.

Thank you for your time, hope Moritz can help me

It’s not entirely clear what problem you’re now facing. You tell us the dar upload is now working; can you explain what you still need help with? What error are you now seeing?

The dar is uploaded to participant1 but when i try to create contracts with participant1 using JSON API i get 404 error

That’s a weird error essage, but let’s assume for a second it may be related to the daml start issue. When you run daml start, by default it will run a local sandbox and run its commands against that. I’m not seeing anything in your daml.yaml or your CLI arguments to overwrite that default behaviour. This means that the parties you have created with your script get created on the sandbox created by daml start, and not on the participants in your domain.

In order to create the parties, you’ll need to run the script against the appropriate participant (I imagine that, as you have two participants, you probably want to create different parties in each one). You can do that with the daml script command, which, unlike daml start, does not start its own sandbox but instead runs against the participant you point it to (run daml script --help for details). You’ll need to first compile the DAR containing your script with daml build, then run something like:

daml script --dar PATH_TO_DAR \
            --ledger-host 192.168.61.128 \
            --ledger-port 5011 \
            --output-file PARTIES_PART1.json \
            --script-name module:function \
            --input-file INPUT_PART1.json

with uppercase things changed to appropriate values (you may or may not need an input-file, depending on the details of your script).

2 Likes

It worked! Thank you very much! :grinning:

The correct party id was the participant’s!

1 Like

Happy to help!

Would you mind marking the question as resolved? You can always open a new thread if you have further questions down the line.

1 Like