genlayer package#
Common import for all contracts
It exposes most of the types to the top scope and encapsulates other utility under
gl
namespace which is a proxy togenlayer.std
- genlayer.gl#
Blockchain specific functionality, that won’t work without GenVM
Proxy to
genlayer.std
- class genlayer.Address[source]#
Bases:
object
Represents GenLayer Address
- SIZE = 20#
Constant that represents size of a Genlayer address
- class genlayer.DynArray[source]#
Bases:
MutableSequence
,Generic
Represents exponentially growing array (
list
in python terms) that can be persisted on the blockchain
- genlayer.Keccak256(initial_input=None)#
- exception genlayer.Rollback[source]#
Bases:
Exception
Exception that will be treated as a “Rollback”
- class genlayer.TreeMap[source]#
Bases:
MutableMapping
,Generic
Represents a mapping from keys to values that can be persisted on the blockchain
- 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
- class genlayer.VecDB[source]#
Bases:
Generic
Data structure that supports storing and querying vector data
There are two entities that can act as a key:
vector (can have duplicates)
id (int alias, can’t have duplicates)
- Id = genlayer.py.storage.vecdb.Id#
- get_by_id(id: Id) VecDBElement[T, S, V, None] [source]#
- Return type:
VecDBElement[T, S, V, None]
- get_by_id_or_none(id: Id) VecDBElement[T, S, V, None] | None [source]#
- Return type:
VecDBElement[T, S, V, None] | None
- knn(v: np.ndarray[tuple[S], np.dtype[T]], k: int) Iterator[VecDBElement[T, S, V, T]] [source]#
- Return type:
Iterator[VecDBElement[T, S, V, T]]
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