Cannot run dazl introductury example
- gyorgybalazsiOP
I’d like to run the following introductory example from the dazl documentation:
import asyncio import dazl async def main(): async with dazl.connect(url='localhost:6865', read_as='Alice') as conn: async for event in conn.creates(): print(event.contract_id, event.payload) # Python 3.7+ or later asyncio.run(main())See dazl.ledger
On ‘localhost:6865’ a sandbox is running.
I get the following error message:
line 6, in main async for event in conn.creates(): AttributeError: 'Connection' object has no attribute 'creates'What am I doing wring?
- dtanabe 1
My apologies: the docs are incorrect.
The correct version is this:
import asyncio import dazl async def main(): async with dazl.connect(url='localhost:6865', read_as='Alice') as conn: async with conn.query('*') as stream: async for event in stream.creates(): print(event.contract_id, event.payload) # Python 3.7+ or later asyncio.run(main())We’ll update the docs as well. Thanks for bringing this to our attention!
- gyorgybalazsi
Perfect, thank you!