Skip to content

Commit 52dba73

Browse files
committed
docs: use algopy.Contract instead of algopy.ARC4Contract
1 parent 8b57fb7 commit 52dba73

15 files changed

+54
-52
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Alternatively, if you want to start from scratch you can do the following:
3333
4. Install Algorand Python into your project `poetry add algorand-python`
3434
5. Create a contract in a (e.g.) `contract.py` file:
3535
```python
36-
from algopy import ARC4Contract, arc4
37-
class HelloWorldContract(ARC4Contract):
36+
from algopy import Contract, arc4
37+
class HelloWorldContract(Contract):
3838
@arc4.abimethod
3939
def hello(self, name: arc4.String) -> arc4.String:
4040
return "Hello, " + name

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Alternatively, if you want to start from scratch you can do the following:
1919
4. Install Algorand Python into your project `poetry add algorand-python`
2020
5. Create a contract in a (e.g.) `contract.py` file:
2121
```python
22-
from algopy import ARC4Contract, arc4
23-
class HelloWorldContract(ARC4Contract):
22+
from algopy import Contract, arc4
23+
class HelloWorldContract(Contract):
2424
@arc4.abimethod
2525
def hello(self, name: arc4.String) -> arc4.String:
2626
return "Hello, " + name

docs/lg-arc28.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ To emit an ARC-28 event in Algorand Python you can use the `emit` function, whic
2121
Here's an example contract that emits events:
2222

2323
```python
24-
from algopy import ARC4Contract, arc4
24+
from algopy import Contract, arc4
2525

2626
class Swapped(arc4.Struct):
2727
a: arc4.UInt64
2828
b: arc4.UInt64
2929

30-
class EventEmitter(ARC4Contract):
30+
class EventEmitter(Contract):
3131
@arc4.abimethod
3232
def emit_swapped(self, a: arc4.UInt64, b: arc4.UInt64) -> None:
3333
arc4.emit(Swapped(b, a))

docs/lg-arc4.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
[ARC-4](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md) defines a set of encodings and behaviors for authoring and interacting with an Algorand Smart Contract. It is not the only way to author a smart contract, but adhering to it will make it easier for other clients and users to interop with your contract.
44

5-
To author an arc4 contract you should extend the `ARC4Contract` base class.
5+
To author an arc4 contract you should extend the `Contract` base class.
66

77
```python
8-
from algopy import ARC4Contract
8+
from algopy import Contract
99

10-
class HelloWorldContract(ARC4Contract):
10+
class HelloWorldContract(Contract):
1111
...
1212
```
1313

@@ -27,10 +27,10 @@ A method that should not be externally available can be optionally annotated wit
2727
Method docstrings will be used when outputting ARC-32 or ARC-56 application specifications, the following docstrings styles are supported ReST, Google, Numpydoc-style and Epydoc.
2828

2929
```python
30-
from algopy import ARC4Contract, subroutine, arc4, public
30+
from algopy import Contract, subroutine, arc4, public
3131

3232

33-
class HelloWorldContract(ARC4Contract):
33+
class HelloWorldContract(Contract):
3434
@arc4.abimethod(create="disallow", allow_actions=["NoOp", "OptIn"], name="external_name")
3535
def hello(self, name: arc4.String) -> arc4.String:
3636
return self.hello_impl() + name
@@ -51,7 +51,7 @@ class HelloWorldContract(ARC4Contract):
5151

5252
Algorand Smart Contracts only have two possible programs that are invoked when making an ApplicationCall Transaction (`appl`). The "clear state" program which is called when using an OnComplete action of `ClearState` or the "approval" program which is called for all other OnComplete actions.
5353

54-
Routing is required to dispatch calls handled by the approval program to the relevant ABI methods. When extending `ARC4Contract`, the routing code is automatically generated for you by the PuyaPy compiler.
54+
Routing is required to dispatch calls handled by the approval program to the relevant ABI methods. When extending `Contract`, the routing code is automatically generated for you by the PuyaPy compiler.
5555

5656
## Types
5757

@@ -202,13 +202,13 @@ These types can only be used as parameters, and not as return types.
202202
from algopy import (
203203
Account,
204204
Application,
205-
ARC4Contract,
205+
Contract,
206206
Asset,
207207
arc4,
208208
gtxn,
209209
)
210210

211-
class Reference(ARC4Contract):
211+
class Reference(Contract):
212212
@arc4.abimethod
213213
def with_transactions(
214214
self,

docs/lg-calling-apps.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ If the ARC-4 method returns an ARC-4 result then the result will be a tuple of t
1717
If the ARC-4 method does not return a result, or if the result type is not fully qualified then just the inner transaction is returned.
1818

1919
```python
20-
from algopy import Application, ARC4Contract, String, arc4, subroutine
20+
from algopy import Application, Contract, String, arc4, subroutine
2121

22-
class HelloWorld(ARC4Contract):
22+
class HelloWorld(Contract):
2323

2424
@arc4.abimethod()
2525
def greet(self, name: String) -> String:
@@ -89,9 +89,9 @@ If the compiled programs and state allocation fields need to be customized (for
8989
this can be done by passing a [`algopy.CompiledContract`](#algopy.CompiledContract) via the `compiled` keyword argument.
9090

9191
```python
92-
from algopy import ARC4Contract, String, arc4, subroutine
92+
from algopy import Contract, String, arc4, subroutine
9393

94-
class HelloWorld(ARC4Contract):
94+
class HelloWorld(Contract):
9595

9696
@arc4.abimethod()
9797
def greet(self, name: String) -> String:
@@ -116,9 +116,9 @@ If the compiled programs need to be customized (for example due to [template var
116116
this can be done by passing a [`algopy.CompiledContract`](#algopy.CompiledContract) via the `compiled` keyword argument.
117117

118118
```python
119-
from algopy import Application, ARC4Contract, String, arc4, subroutine
119+
from algopy import Application, Contract, String, arc4, subroutine
120120

121-
class NewApp(ARC4Contract):
121+
class NewApp(Contract):
122122

123123
@arc4.abimethod()
124124
def greet(self, name: String) -> String:

docs/lg-compile.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ For example, the following contract has `UInt64` and `Bytes` template variables.
2424

2525
```{code-block} python
2626
:caption: templated_contract.py
27-
from algopy import ARC4Contract, Bytes, TemplateVar, UInt64, arc4
27+
from algopy import Contract, Bytes, TemplateVar, UInt64, arc4
2828
2929
30-
class TemplatedContract(ARC4Contract):
30+
class TemplatedContract(Contract):
3131
3232
@arc4.abimethod
3333
def my_method(self) -> UInt64:

docs/lg-data-structures.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ However Puya will support reading and writing parts of a box
8383

8484
```python
8585
import typing
86-
from algopy import Box, FixedArray, Struct, UInt64, arc4, size_of
86+
from algopy import Box, Contract, FixedArray, Struct, UInt64, arc4, size_of
8787

8888

8989

9090
class BigStruct(Struct):
9191
count: UInt64 # 8 bytes
9292
large_array: FixedArray[UInt64, typing.Literal[512]] # 4096 bytes
9393

94-
class Contract(arc4.ARC4Contract):
94+
class Contract(Contract):
9595

9696
def __init__(self) -> None:
9797
self.box = Box(BigStruct)
@@ -179,7 +179,7 @@ This is a regular python tuple
179179
```python
180180
import algopy
181181

182-
class SomeContract(algopy.arc4.ARC4Contract):
182+
class SomeContract(algopy.Contract):
183183
@algopy.arc4.abimethod()
184184
def get_array(self) -> algopy.ImmutableArray[algopy.UInt64]:
185185
arr = algopy.ReferenceArray[algopy.UInt64]()

docs/lg-migration-4-5.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ Individual methods can be forced to use the original behaviour by setting the `r
7070
on `arc4.abimethod` e.g.
7171

7272
```python
73-
from algopy import arc4, Account, Application, Asset
73+
from algopy import arc4, Account, Application, Asset, Contract
7474

75-
class MyContract(arc4.ARC4Contract):
75+
class MyContract(Contract):
7676
@arc4.abimethod(resource_encoding="index")
7777
def my_abi_method(self, app: Application, asset: Asset, account: Account) -> None:
7878
...

docs/lg-structure.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ consists of two distinct "programs"; an approval program, and a
9191
clear-state program. These are tied together in Algorand Python as a single class.
9292

9393
All contracts must inherit from the base class `algopy.BaseContract` - either directly or indirectly,
94-
which can include inheriting from `algopy.ARC4Contract`.
94+
which can include inheriting from `algopy.ARC4Contract` or its alias, `algopy.Contract`.
9595

9696
The life-cycle of a smart contract matches the semantics of Python classes when you consider
9797
deploying a smart contract as "instantiating" the class. Any calls to that smart contract are made
@@ -209,12 +209,12 @@ Some things to note:
209209
- Any methods other than `__init__`, `approval_program` or `clear_state_program` must be decorated
210210
with `@subroutine`.
211211

212-
### Example: Simplest possible `algopy.ARC4Contract` implementation
212+
### Example: Simplest possible `algopy.Contract` implementation
213213

214214
And here is a valid ARC-4 contract:
215215

216216
```python
217-
class ABIContract(algopy.ARC4Contract):
217+
class ABIContract(algopy.Contract):
218218
pass
219219
```
220220

@@ -231,7 +231,7 @@ A default `clear_state_program` is implemented which always approves, but this c
231231
```python
232232
import algopy
233233

234-
class ARC4Counter(algopy.ARC4Contract):
234+
class ARC4Counter(algopy.Contract):
235235
def __init__(self) -> None:
236236
self.counter = algopy.UInt64(0)
237237

@@ -255,9 +255,11 @@ Things to note here:
255255
- The default options for `abimethod` is to only allow `NoOp` as an on-completion-action, so we
256256
don't need to check this manually.
257257
- The current call count is returned from the `invoke` method.
258-
- Every method in an `ARC4Contract` except for the optional `__init__` and `clear_state_program`
259-
methods must be decorated with one of `algopy.arc4.abimethod`, `algopy.arc4.baremethod`, or
260-
`algopy.subroutine`. `subroutines` won't be directly callable through the default router.
258+
- Every method in an `Contract` except for the optional `__init__` and `clear_state_program`
259+
methods must be decorated with one of `algopy.arc4.baremethod`, `algopy.arc4.abimethod`
260+
(or its alias, `public`), to indicate that they are externally callable. Other methods which won't
261+
be directly callable through the default router can be optionally decorated with
262+
`algopy.subroutine` decorator.
261263

262264
See the [ARC-4 section](lg-arc4.md) of this language guide for more info on the above.
263265

docs/lg-transactions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ For example to require a payment transaction in an ARC-4 ABI method:
2929
import algopy
3030

3131

32-
class MyContract(algopy.ARC4Contract):
32+
class MyContract(algopy.Contract):
3333

3434
@algopy.arc4.abimethod()
3535
def process_payment(self, payment: algopy.gtxn.PaymentTransaction) -> None:

0 commit comments

Comments
 (0)