daml账本的高级账本api客户端
dazl的Python项目详细描述
DAZL
版权所有2019 Digital Asset(Switzerland)GmbH和/或其附属公司。保留所有权利。 SPDX许可证标识符:apache-2.0
用于访问基于ledger api的应用程序的富python绑定。
要求
示例
下面的所有示例都假设您导入了dazl
。
连接到分类账并提交一个命令:
withdazl.simple_client('http://localhost:7600','Alice')asclient:client.submit_create('Alice','My.Template',{someField:'someText'})
作为一方连接到分类账,打印所有合同,然后关闭:
withdazl.simple_client('http://localhost:7600','Alice')asclient:# wait for the ACS to be fully readclient.ready()contract_dict=client.find_active('*')print(contract_dict)
作为多方连接到分类账:
network=dazl.Network()network.set_config(url='http://localhost:7600')alice=network.simple_party('Alice')bob=network.simple_party('Bob')@alice.ledger_ready()defset_up(event):currency_cid,_=awaitevent.acs_find_one('My.Currency',{"currency":"USD"})returndazl.create('SomethingOf.Value',{'amount':100,'currency':currency_cid,'from':'Accept','to':'Bob'})@bob.ledger_created('SomethingOf.Value')defon_something_of_value(event):returndazl.exercise(event.cid,'Accept',{'message':'Thanks!'})network.start()
本地建筑
cd python && pipenv run package
测试
cd python && pipenv run test