Introduction
I learned how to use the gRPC UI to explore the Ledger API. Here are my notes (using Daml SDK 2.4.0.)
Getting Started
You do not need a Daml model to try out the grpcui
.
-
In one terminal window, start the Daml Sandbox ledger with
daml sandbox
. -
In a second terminal window, start the gRPC UI with
grpcui -plaintext localhost:6865
.At this point,
grpcui
should launch a browser window. You will know that it is working if the UI includes a dropdown box with the various Ledger API services listed. -
In the dropdown, select the “VersionService” and press the Invoke button.
After pressing Invoke, you should see a JSON-formatted response with the version number and other information.
Allocating Parties
-
In the “Service name” dropdown, select the “PartyManagementService”.
-
In the “Method name” dropdown, select “AllocateParty.”
-
In the “Request Data” section, set the
party_id_hint
anddisplay_name
. I used “owner” and “owner” for both. -
Press the Invoke button and look at the Response Data.
-
Compare the Response Data with the documentation for the AllocatePartyResponse.
Viewing Results of Daml Scripts
-
Create a simple Daml model. For example,
daml new intro4 --template daml-intro-4
. -
cd
into the project folder and rundaml build
. -
Load your model into the Sandbox ledger. For example,
daml ledger upload-dar .daml/dist/intro4-1.0.0.dar
. -
Run one of the scripts in your Daml model. For example,
daml script --dar .daml/dist/intro4-1.0.0.dar --ledger-host localhost --ledger-port 6865 --script-name SimpleIou:test_iou
-
In the gRPC UI, explore the results of running your script. For example, running the PartyManagementService’s ListKnownParties method shows me that the parties Alice, Bob, Charlie, and Dora have all been created.
-
Use the gRPC UI and the TransactionService’s GetTransactionTrees method to see the transactions visible to a party.
.Where did the value for the
filters_by_party
key come from? That was available in the result of the call to ListKnownParties.After pressing the Invoke button, you should see a collection of GetTransactionTreeResult objects.
Adding to the Ledger
You can use the CommandService’s SubmitAndWaitTransaction method to create contracts and exercise choices. However, this can be very tedious and may be of limited utility.