Skip to main content

high-level Ledger API client for DAML ledgers

Project description

dazl

License

Copyright (c) 2017-2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Rich Python bindings for accessing Ledger API-based applications.

Documentation

The user documentation is available online here.

Installation

If you just want to use the library, you can install it locally with pip:

pip install --user dazl

Requirements

  • Python 3.6+
  • Daml Connect
  • Python gRPC libraries (1.32.0 or later) and Protobuf

WARNING: The next major version of dazl (v8.0.0) will require Python 3.7 or later.

Examples

All of the examples below assume you imported dazl, and are running a ledger with the default scenario generated with daml new.

Connect to the ledger and submit a single command:

import asyncio
import dazl

async def main():
    async with dazl.connect('http://localhost:6865', act_as='Alice') as client:
        contract = { 'issuer' : 'Alice', 'owner' : 'Alice', 'name' : 'hello world!' }
        await client.create('Main:Asset', contract)

# Python 3.7+
asyncio.run(main())

# Python 3.6+
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

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

import asyncio
import dazl
from dazl.ledgerutil import ACS

async def main():
    async with dazl.connect('http://localhost:6865', read_as='Alice') as conn:
        async with ACS(conn, {"*": {}}) as acs:
            snapshot = await acs.read()
            
    print(snapshot)

# Python 3.7+
asyncio.run(main())

# Python 3.6+
loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Building locally

You will need additional dependencies to build locally:

  • GNU Make
  • Poetry for build/dependency management

Once you have these prerequisites in place:

make build

If you see errors about incompatible python versions, switch your environment to python3 using poetry env use python3, for instance.

Tests

Tests in dazl are written using pytest. You can run them by doing:

make test

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dazl-7.5.2.tar.gz (325.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dazl-7.5.2-py3-none-any.whl (454.8 kB view details)

Uploaded Python 3

File details

Details for the file dazl-7.5.2.tar.gz.

File metadata

  • Download URL: dazl-7.5.2.tar.gz
  • Upload date:
  • Size: 325.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.6.13 Darwin/20.4.0

File hashes

Hashes for dazl-7.5.2.tar.gz
Algorithm Hash digest
SHA256 c72cb2fbd527c498f1cfb1d48232df51ddd5708ffb5cd68c22011fee54849916
MD5 405894c46aea09f3eabfeab26728dc17
BLAKE2b-256 5524dec3a3671a37484c7e34f485e42c6b060ab078edcbd3d3bbadc9c78bf2c8

See more details on using hashes here.

File details

Details for the file dazl-7.5.2-py3-none-any.whl.

File metadata

  • Download URL: dazl-7.5.2-py3-none-any.whl
  • Upload date:
  • Size: 454.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.6.13 Darwin/20.4.0

File hashes

Hashes for dazl-7.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e2b94df3af0207e1f706a149ea0464d69c545fb99e77e083e984ea604c80e9e
MD5 a8efa9ef5f64856d1faab98feeb8daae
BLAKE2b-256 c844a975851ebc494c5467bae9a463dbe960a7cc0ba2c9303fa528996933a61c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page