|
4 | 4 | dazl: DA client library for Python |
5 | 5 | ================================== |
6 | 6 |
|
7 | | -*Version: |release|* |
| 7 | +Version |release| |
8 | 8 |
|
9 | 9 | Dependencies |
10 | 10 | ------------ |
11 | 11 |
|
12 | 12 | You will need Python 3.6 or later and a Daml Ledger. |
13 | 13 |
|
14 | | - |
15 | 14 | Getting Started |
16 | 15 | --------------- |
17 | 16 |
|
18 | 17 | This section assumes that you already have a running ledger with the standard `daml new` model |
19 | 18 | loaded, and have imported `dazl`. |
20 | 19 |
|
21 | | -Connect to the ledger and submit a single command:: |
22 | | - |
23 | | - import dazl |
24 | | - |
25 | | - async with dazl.connect(url='http://localhost:6865', act_as='Alice') as conn: |
26 | | - await conn.create('Main:Asset', {'issuer': 'Alice', 'owner': 'Alice', 'name': 'hello world!'}) |
| 20 | +Connect to the ledger and submit a single command: |
27 | 21 |
|
28 | | -Connect to the ledger as a single party, print all contracts, and close:: |
| 22 | +.. literalinclude:: ../python/tests/unit/test_docs.py |
| 23 | + :language: python |
| 24 | + :pyobject: test_send_single_command |
| 25 | + :lines: 2- |
| 26 | + :dedent: 4 |
29 | 27 |
|
30 | | - import dazl |
| 28 | +Connect to the ledger as a single party, print all contracts, and close: |
31 | 29 |
|
32 | | - async with dazl.connect(url='http://localhost:6865', read_as='Alice') as conn: |
33 | | - contracts = {} |
34 | | - async for event in conn.query(): |
35 | | - contracts[event.cid] = event.cdata |
36 | | - print(contracts) |
| 30 | +.. literalinclude:: ../python/tests/unit/test_docs.py |
| 31 | + :language: python |
| 32 | + :pyobject: test_read |
| 33 | + :lines: 2- |
| 34 | + :dedent: 4 |
37 | 35 |
|
38 | | -Connect to the ledger using asynchronous callbacks:: |
| 36 | +Connect to the ledger using asynchronous callbacks: |
39 | 37 |
|
40 | | - import dazl |
| 38 | +.. literalinclude:: ../python/tests/unit/test_docs.py |
| 39 | + :language: python |
| 40 | + :pyobject: test_read_using_callback |
| 41 | + :lines: 2- |
| 42 | + :dedent: 4 |
41 | 43 |
|
42 | | - async with dazl.connect(url='http://localhost:6865', read_as='Alice') as conn: |
43 | | - contracts = {} |
44 | | - @conn.on_create |
45 | | - def _(event): |
46 | | - contracts[event.cid] = event.cdata |
47 | | - print(contracts) |
48 | 44 |
|
49 | 45 | Code |
50 | 46 | ---- |
|
0 commit comments