Skip to main content

high-level Ledger API client for DAML ledgers

Project description

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.

Requirements

  • Python 3.6+
  • Poetry
  • Although not strictly required for building, you'll probably want the DAML SDK

Examples

All of the examples below assume you imported dazl.

Connect to the ledger and submit a single command:

with dazl.simple_client('http://localhost:7600', 'Alice') as client:
    client.submit_create('Alice', 'My.Template', { someField: 'someText' })

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

with dazl.simple_client('http://localhost:7600', '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 as multiple parties:

network = dazl.Network()
network.set_config(url='http://localhost:7600')

alice = network.simple_party('Alice')
bob = network.simple_party('Bob')

@alice.ledger_ready()
def set_up(event):
    currency_cid, _ = await event.acs_find_one('My.Currency', {"currency": "USD"})
    return dazl.create('SomethingOf.Value', {
        'amount': 100,
        'currency': currency_cid,
        'from': 'Accept',
        'to': 'Bob' })

@bob.ledger_created('SomethingOf.Value')
def on_something_of_value(event):
    return dazl.exercise(event.cid, 'Accept', { 'message': 'Thanks!' })

network.start()

Building locally

make package

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-6.7.3.tar.gz (226.2 kB view hashes)

Uploaded Source

Built Distribution

dazl-6.7.3-py3-none-any.whl (319.1 kB view hashes)

Uploaded Python 3

Supported by

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