Skip to content

lucianojoublanc-da/dazl-client

 
 

Repository files navigation

dazl

License

Copyright 2019 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+
  • Poetry for build/dependency management
  • Although not strictly required for building, you'll probably want the DAML SDK

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:

with dazl.simple_client('http://localhost:6865', 'Alice') as client:
    contract = { 'issuer' : 'Alice', 'owner' : 'Alice', 'name' : 'hello world!' }
    client.ready()
    client.submit_create('Main.Asset', contract)

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

with dazl.simple_client('http://localhost:6865', 'Alice') as client:
    # wait for the ACS to be fully read
    client.ready()
    contract_dict = client.find_active('*')
print(contract_dict)

Connect to the ledger using asynchronous callbacks:

from dazl.model.reading import ReadyEvent
network = dazl.Network()
network.set_config(url='http://localhost:6865')

alice = network.aio_party('Alice')

@alice.ledger_ready()
async def onReady(event: ReadyEvent):
  contracts = await event.acs_find_one('Main.Asset')
  print(contracts)

network.run_until_complete()

Building locally

You will need to have Poetry installed, and the dependencies fetched using poetry install. Then do:

make build

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

Building Documentation

The above command will build documentation in the root docs/ dir. Committing this into source control and pushing to github will cause github-pages to be updated.

Tests

make test

About

dazl Ledger API client

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.2%
  • Other 0.8%