1

I am in the process of writing a DA Ledger client application. It's going slow because the API documentation does not explain how to combine the provided services to do simple Create, read, update, and delete on the Ledger.
For example there is no simple service that allows the client to read all contacts from a given party directly. First the client needs to get the ledger id, and then (I think) the package id. etc. There is a service to read active contracts, but what about inactive contracts? It would be helpful to have some documentation that explains and demonstrates how to combine calls to the various services to (for example):

  • Read all contracts for a given party
  • Exercize a choice on a given contract
  • Create a new contract

My application is being written in php. I don't necessarily need examples in php but I just want to know how do use the provided services to accomplish simple tasks.

4

1 回答 1

1

阅读给定方的所有合同

DAML Ledger 是一个固有的事件驱动系统。因此,它不像传统数据库那样提供查询访问。相反,您的应用程序使用GetTransactionsRequest订阅TransactionService并指定LEDGER_BEGIN作为偏移量。这将为您提供自分类帐启动以来发生的所有事件和事件。在您的应用程序中,您可以使用这些事件来构建分类帐的表示形式(内存中的或持久的),然后您可以方便地对其进行查询。例如,您可以按合同类型填充字典,为每个事件添加一个条目,并在收到事件时再次删除它。beginCreatedArchivedCreatedArchived

创建合约或行使选择权

有两种方法可以做到这一点:

  • 通过CommandSubmissionService提交创建或练习命令,Submit并等待CommandCompletionService上的成功或错误消息。请注意,接收到此类命令完成消息仅确认该命令可以被分类帐成功接收。它不会包含来自该命令的任何效果(创建和存档事件)。这些您将再次收到上述内容。TransactionService

  • SubmitAndWait通过CommandService提交创建或练习命令。该服务将命令提交和完成结合到服务器端的同步调用中,因此只有在命令被服务器接受或拒绝后才会返回。使用这种命令提交方式通常更方便,因为它处理了前一种方法所需的一些异步事件处理。

TransactionService请注意,您可以从使用上述方法构建的分类帐表示中获取行使选择所需的合约 ID 。

于 2019-03-05T08:24:34.243 回答