dazl

dazl: DA client library for Python

Version 7.5.15

Dependencies

You will need Python 3.6 or later and a Daml Ledger.

Getting Started

This section assumes that you already have a running ledger with the standard daml new model loaded, and have imported dazl.

Connect to the ledger and submit a single command:

import dazl

async with dazl.connect(url="http://localhost:6865", act_as=dazl.Party("Alice")) as conn:
    payload = {"issuer": "Alice", "owner": "Alice", "name": "hello world!"}
    await conn.create("Main:Asset", payload)

Connect to the ledger as a single party, print all contracts, and close:

import dazl

async with dazl.connect(url="http://localhost:6865", read_as=dazl.Party("Alice")) as conn:
    contracts = {}
    async with conn.query("Main:Asset") as stream:
        async for event in stream.creates():
            contracts[event.contract_id] = event.payload
print(contracts)

Connect to the ledger using asynchronous callbacks:

import dazl

async with dazl.connect(url="http://localhost:6865", read_as=dazl.Party("Alice")) as conn:
    contracts = {}
    async with conn.query("Main:Asset") as stream:

        @stream.on_create
        def _(event):
            contracts[event.contract_id] = event.payload

        await stream.run()
print(contracts)

Code

Build-time dependencies are handled using Poetry.

Support

The dazl library is supported by the Daml community. If you are in need of support, have questions or just want to engage in friendly conversation anything Daml, contact us on our Daml Community Forum.

Table of Contents