Using gRPC UI to Explore the Ledger API

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.

  1. Install gRPC UI. (On a Mac, I used homebrew.)

  2. In one terminal window, start the Daml Sandbox ledger with daml sandbox.

  3. 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.

  4. 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

  1. In the “Service name” dropdown, select the “PartyManagementService”.

  2. In the “Method name” dropdown, select “AllocateParty.”

  3. In the “Request Data” section, set the party_id_hint and display_name. I used “owner” and “owner” for both.

  4. Press the Invoke button and look at the Response Data.

  5. Compare the Response Data with the documentation for the AllocatePartyResponse.

Viewing Results of Daml Scripts

  1. Create a simple Daml model. For example,
    daml new intro4 --template daml-intro-4.

  2. cd into the project folder and run daml build.

  3. Load your model into the Sandbox ledger. For example,
    daml ledger upload-dar .daml/dist/intro4-1.0.0.dar.

  4. 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

  5. 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.

  6. 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.

3 Likes