Is there a way to obtain the package ID without uploading a dar to a ledger?

I use daml packages list to obtain the package ID of deployed packages.

Is there a way to obtain the package ID of a package without deploying it to a ledger, just by looking at its DAR?

Thanks a lot,
mesch.

2 Likes

Hi @mesch,

[EDIT]
Since this is marked as the solution, I’ve updated it to use inspect-dar instead of inspect based on @cocreature’s comment below.
[/EDIT]

There is

daml damlc inspect-dar <path/to/dar>

Full example:

$ cd $(mktemp -d)
$ daml new t
Created a new project in "t" based on the template "skeleton".
$ cd t
$ daml build

2022-08-09 13:41:44.39 [INFO]  [build]
Compiling t to a DAR.

2022-08-09 13:41:45.08 [INFO]  [build]
Created .daml/dist/t-0.0.1.dar
$ daml damlc inspect-dar .daml/dist/t-0.0.1.dar --json | grep package_id
    "main_package_id": "76fda6460d5253cf41165c2bb4ba1208a67b6d1bf953dd209bf6511fa9ea2c9d",
$ daml damlc inspect-dar .daml/dist/t-0.0.1.dar --json | jq -r .main_package_id
76fda6460d5253cf41165c2bb4ba1208a67b6d1bf953dd209bf6511fa9ea2c9d
$
3 Likes

Excellent, thank you very much.

One caveat for future readers: the bash autocompletion that comes with the daml SDK for the daml tool completes daml damlc ins| straight to daml damlc inspect-dar, which gives different information as far as I can tell.

1 Like

I strongly recommend to use daml damlc inspect-dar for this actually, especially the --json option which deliberately provides this in a machine readable form. daml damlc inspect is intended for debugging the generate daml-lf not to provide package metadata.

1 Like

Updated accepted answer to use inspect-dar.

Alright, see it!

Thanks,
mesch.