dazl

dazl: DA client library for Python

Version 7.11.0

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:

est.mark.skip("typecheck only")
c def test_send_single_command() -> None:
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:

est.mark.skip("typecheck only")
c def test_read() -> None:
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:

est.mark.skip("typecheck only")
c def test_read_using_callback() -> None:
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