ARC4 Types
These types are available under the algopy.arc4 namespace. Refer to the ARC4 specification for more details on the spec.
Tip
The test context manager provides value generators for ARC4 types. To access the value generators, use {context_instance}.any.arc4 property. See more examples below.
Note
For all algopy.arc4 types with and without respective value generator, instantiation can be performed directly. If you have a suggestion for a new value generator implementation, please open an issue in the algorand-python-testing repository or contribute by following the contribution guide.
Unsigned Integers
Section titled “Unsigned Integers”from algopy import arc4
# Integer typesuint8_value = arc4.UInt8(255)uint16_value = arc4.UInt16(65535)uint32_value = arc4.UInt32(4294967295)uint64_value = arc4.UInt64(18446744073709551615)
... # instantiate test context# Generate a random unsigned arc4 integer with default rangeuint8 = context.any.arc4.uint8()uint16 = context.any.arc4.uint16()uint32 = context.any.arc4.uint32()uint64 = context.any.arc4.uint64()biguint128 = context.any.arc4.biguint128()biguint256 = context.any.arc4.biguint256()biguint512 = context.any.arc4.biguint512()
# Generate a random unsigned arc4 integer with specified rangeuint8_custom = context.any.arc4.uint8(min_value=10, max_value=100)uint16_custom = context.any.arc4.uint16(min_value=1000, max_value=5000)uint32_custom = context.any.arc4.uint32(min_value=100000, max_value=1000000)uint64_custom = context.any.arc4.uint64(min_value=1000000000, max_value=10000000000)biguint128_custom = context.any.arc4.biguint128(min_value=1000000000000000, max_value=10000000000000000)biguint256_custom = context.any.arc4.biguint256(min_value=1000000000000000000000000, max_value=10000000000000000000000000)biguint512_custom = context.any.arc4.biguint512(min_value=10000000000000000000000000000000000, max_value=10000000000000000000000000000000000)Address
Section titled “Address”from algopy import arc4
# Address typeaddress_value = arc4.Address("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ")
# Generate a random addressrandom_address = context.any.arc4.address()
# Access native underlying typenative = random_address.nativeDynamic Bytes
Section titled “Dynamic Bytes”from algopy import arc4
# Dynamic byte stringbytes_value = arc4.DynamicBytes(b"Hello, Algorand!")
# Generate random dynamic bytesrandom_dynamic_bytes = context.any.arc4.dynamic_bytes(n=123) # n is the number of bits in the ARC4 dynamic bytesString
Section titled “String”from algopy import arc4
# UTF-8 encoded stringstring_value = arc4.String("Hello, Algorand!")
# Generate random stringrandom_string = context.any.arc4.string(n=12) # n is the number of bits in the ARC4 string