How to get package_id for submit_command with gRPC

There’s no real safe way of doing that on a shared ledger. Imagine you uploaded a package Foo and someone else also uploaded a malicious package Foo. If you just look for some package Foo at runtime, you run the risk of accidentally picking up the wrong one.

If you have full control of the Participant node and can thus make sure there is only one such, you can do this:

Use the PackageService to first list all package Ids using ListPackages, then fetch each package using GetPackage and deserialize them until you find one that matches what you are looking for.

The deserialization is demonstrated using JavaScript here.

1 Like