You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -8,10 +8,10 @@ Typed application clients are the recommended way of interacting with smart cont
8
8
9
9
You can generate an app spec file:
10
10
11
-
- Using [Algorand Python](https://algorandfoundation.github.io/puya/#quick-start)
12
-
- Using [TEALScript](https://tealscript.netlify.app/tutorials/hello-world/0004-artifacts/)
13
-
- By hand by following the specification [ARC-56](https://github.com/algorandfoundation/ARCs/pull/258)/[ARC-32](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0032.md)
14
-
- Using [Beaker](https://algorand-devrel.github.io/beaker/html/usage.html) (PyTEAL) _(DEPRECATED)_
11
+
- Using [Algorand Python](https://algorandfoundation.github.io/puya/#quick-start)
12
+
- Using [TEALScript](https://tealscript.netlify.app/tutorials/hello-world/0004-artifacts/)
13
+
- By hand by following the specification [ARC-56](https://github.com/algorandfoundation/ARCs/pull/258)/[ARC-32](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0032.md)
14
+
- Using [Beaker](https://algorand-devrel.github.io/beaker/html/usage.html) (PyTEAL) _(DEPRECATED)_
15
15
16
16
## Generating a typed client
17
17
@@ -27,174 +27,158 @@ Note: AlgoKit Utils >= 3.0.0 is compatible with the older 1.x.x generated typed
27
27
28
28
To get an instance of a typed client you can use an [`AlgorandClient`](./algorand-client.md) instance or a typed app [`Factory`](#creating-a-typed-factory-instance) instance.
29
29
30
-
The approach to obtaining a client instance depends on how many app clients you require for a given app spec and if the app has already been deployed, which is summarised below:
30
+
The approach to obtaining a client instance depends on how many app clients you require for a given app spec and if the app has already been deployed:
31
31
32
32
### App is deployed
33
33
34
-
<table>
35
-
<thead>
36
-
<tr>
37
-
<th colspan="2">Resolve App by ID</th>
38
-
<th colspan="2">Resolve App by Creator and Name</th>
# Typed: Using the AlgorandClient extension method
134
+
typed_factory = algorand.client.get_typed_app_factory(MyContractFactory) # Generated factory class
135
+
# or Typed: Using the factory class constructor directly
136
+
typed_factory = MyContractFactory(algorand)
168
137
```
169
138
170
139
## Client usage
171
140
172
-
See the [official usage docs](https://github.com/algorandfoundation/algokit-client-generator-py/blob/main/docs/usage.md) for full details.
141
+
See the [official usage docs](https://github.com/algorandfoundation/algokit-client-generator-py/blob/main/docs/usage.md) for full details about typed clients.
173
142
174
-
For a simple example that deploys a contractand calls a `"hello"` method, see below:
143
+
Below is a realistic example that deploys a contract, funds it if newly created, and calls a `"hello"` method:
175
144
176
145
```python
177
-
# A similar working example can be seen in the AlgoKit init production smart contract templates, when using Python deployment
178
-
# In this case the generated factory is called `HelloWorldAppFactory` and is in `./artifacts/HelloWorldApp/client.py`
179
-
from artifacts.hello_world_app.client import HelloWorldAppClient, HelloArgs
180
-
from algokit_utils import AlgorandClient
146
+
# Typed: Complete example using a typed application client
147
+
import algokit_utils
148
+
from artifacts.hello_world.hello_world_client import (
149
+
HelloArgs, # Generated args class
150
+
HelloWorldFactory, # Generated factory class
151
+
)
181
152
182
-
# These require environment variables to be present, or it will retrieve from default LocalNet
0 commit comments