Common Utilities
Utility functions and helpers.
Examples (12)
Section titled “Examples (12)”| Example | Description |
|---|---|
| Address Basics | This example demonstrates basic address operations using the algokit_common module:
|
| Address Encoding | This example demonstrates how to encode and decode addresses between different formats and compute application addresses:
|
| Array Utilities | This example demonstrates array utility operations for comparing and concatenating byte arrays in Python:
Note: Python’s bytes type provides native support for these operations, unlike JavaScript’s Uint8Array which needs utility functions. |
| Constants Reference | This example displays all the protocol constants available in the algokit_common package. These constants define limits, sizes, and separators used throughout Algorand. |
| Crypto Hash (SHA-512/256) | This example demonstrates the sha512_256() function for computing Algorand-compatible SHA-512/256 hashes. This hash algorithm is used throughout Algorand for:
|
| Example | Logger Type Example This example demonstrates the Logger protocol/interface for consistent logging across the AlgoKit Utils SDK. Topics covered:
|
| JSON BigInt Support | This example demonstrates how Python handles large integers in JSON, which is simpler than JavaScript due to Python’s native arbitrary-precision integers. Topics covered:
|
| MessagePack Encoding | This example demonstrates encoding and decoding MessagePack data, which is used for Algorand transaction encoding. Topics covered:
|
| Primitive Serde (Serialization/Deserialization) | This example demonstrates how to use primitive serialization patterns in Python for encoding/decoding basic values in wire format. Note: Unlike the TypeScript SDK which uses explicit codec classes (numberCodec, bigIntCodec, etc.), the Python SDK uses a dataclass-based approach with field metadata helpers. This example shows both native Python serialization and the serde utilities available in algokit_common. Topics covered:
|
| Composite Serde (Serialization/Deserialization) | This example demonstrates how to serialize/deserialize composite data structures like arrays, maps, and records in Python using the serde utilities. Note: Unlike the TypeScript SDK which uses explicit ArrayCodec, MapCodec, and RecordCodec classes, the Python SDK handles these natively through:
Topics covered:
|
| Model Serde (Object Model Serialization) | This example demonstrates how to use dataclass-based serialization for complex object structures with field metadata in Python. Note: Unlike the TypeScript SDK which uses ObjectModelCodec, PrimitiveModelCodec, and ArrayModelCodec classes, the Python SDK uses dataclasses with field metadata helpers. This is a more Pythonic approach that achieves the same goals. Topics covered:
|
| Sourcemap for TEAL Debugging | This example demonstrates how to use ProgramSourceMap for mapping TEAL program counters (PC) to source locations for debugging purposes. Topics covered:
|
Quick Start
Section titled “Quick Start”Run any example from the repository’s examples directory:
cd examplesuv run python common/01_address_basics.py