Package genlayer#
Common import for all contracts
It exposes most of the types to the top scope and encapsulates other utility under
glnamespace which is a proxy togenlayer.std
- genlayer.gl#
Blockchain specific functionality, that won’t work without GenVM and reexports form
genlayer.pyprovided for convenienceProxy to
genlayer.std
- class genlayer.Address[source]#
Bases:
objectRepresents GenLayer Address
- __format__(fmt: Literal['x', 'b64', 'cd', '']) str[source]#
Default object formatter.
Return str(self) if format_spec is empty. Raise TypeError otherwise.
- Return type:
- __init__(val: str | Buffer)[source]#
- Parameters:
val (str | Buffer) – either a hex encoded address (that starts with ‘0x’), or base64 encoded address, or buffer of 20 bytes
Warning
checksum validation is not performed
- property as_b64: str#
>>> Address('0x5b38da6a701c568545dcfcb03fcb875f56beddc4').as_b64 'WzjaanAcVoVF3PywP8uHX1a+3cQ='
- Returns:
base64 representation of an address (most compact string)
- property as_bytes: bytes#
>>> Address('0x5b38da6a701c568545dcfcb03fcb875f56beddc4').as_bytes b'[8\xdajp\x1cV\x85E\xdc\xfc\xb0?\xcb\x87_V\xbe\xdd\xc4'
- Returns:
raw bytes of an address (most compact representation)
- property as_hex: str#
>>> Address('0x5b38da6a701c568545dcfcb03fcb875f56beddc4').as_hex '0x5B38Da6a701c568545dCfcB03FcB875f56beddC4'
- Returns:
checksum string representation
- property as_int: u160#
>>> Address('0x5b38da6a701c568545dcfcb03fcb875f56beddc4').as_int 1123907236495940146162314350759402901750813440091 >>> hex(Address('0x5b38da6a701c568545dcfcb03fcb875f56beddc4').as_int) '0xc4ddbe565f87cb3fb0fcdc4585561c706ada385b'
- Returns:
int representation of an address (unsigned little endian)
- class genlayer.Array[source]#
Bases:
Sequence,SizedArray,GenericConstantly sized array that can be persisted on the blockchain
- __getitem__(idx: SupportsIndex) T[source]#
- __getitem__(idx: slice) Array
- class genlayer.DynArray[source]#
Bases:
MutableSequence,GenericRepresents exponentially growing array (
listin python terms) that can be persisted on the blockchain- __setitem__(idx: SupportsIndex, val: T) None[source]#
- __setitem__(idx: slice, val: collections.abc.Sequence[T]) None
- exception genlayer.Rollback[source]#
Bases:
ExceptionException that will be treated as a “Rollback”
- class genlayer.TreeMap[source]#
Bases:
MutableMapping,GenericRepresents a mapping from keys to values that can be persisted on the blockchain
- Tparam K:
must implement
genlayer.py.storage.tree_map.Comparableprotocol (“<” is needed) and be storage-allowed- Tparam V:
must be storage-allowed
- __gl_allow_storage__ = True#
- compute_if_absent(k: K, supplier: Callable[[], V]) V[source]#
- Returns:
Value associated with k if it is present, otherwise get’s new value from the supplier, stores it at k and returns
- Return type:
V
Integer aliases#
It also have aliases for signed and unsigned integer types (such as u256) and bigint alias that can be used in storage unlike regular int