high-level Ledger API client for Daml ledgers
Project description
Daml Python bindings (formerly known as dazl)
Copyright (c) 2017-2024 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.8 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(url='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(url='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 4.3 or later
- 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 the Daml Python bindings are written using pytest. You can run them by doing:
make test
Support
The Daml Python bindings library is supported under the Daml Enterprise license. If you do not have a Daml Enterprise license and are in need of support, have questions or just want to engage in friendly conversation anything Daml, contact us on our Daml Community Forum.
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
Built Distribution
File details
Details for the file dazl-7.12.0.tar.gz
.
File metadata
- Download URL: dazl-7.12.0.tar.gz
- Upload date:
- Size: 538.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.3 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7db7a62da3a1d4f1c1bd0026332d3a2568273aa772fe42c1c80661e14f208717 |
|
MD5 | f7c0d9dedc3fc8858e9935415655305d |
|
BLAKE2b-256 | ade28f75af3b8dc5b389f11f1bed260142e664e03a333453f1d0d5464af3c4d0 |
File details
Details for the file dazl-7.12.0-py3-none-any.whl
.
File metadata
- Download URL: dazl-7.12.0-py3-none-any.whl
- Upload date:
- Size: 898.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.3 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a70d85617d68c99ce34d66df3bf711e740197fbf25ffe93114e9a11c892bcfd |
|
MD5 | bde8652ca4106b52e38976981f9a87d0 |
|
BLAKE2b-256 | 35d8d88beb3596bae9919c14be091a3365feb716a47f21d4c16b5de97a540cb8 |