genlayer.std package#
Blockchain specific functionality, that won’t work without GenVM
- class genlayer.std.ContractAt[source]#
Bases:
GenVMContractProxy
Provides a way to call view methods and send transactions to GenVM contracts
- emit(**data: Unpack[TransactionDataKwArgs])[source]#
Namespace with write message
- class genlayer.std.MessageType[source]#
Bases:
NamedTuple
MessageType(contract_account, sender_account, origin_account, value, is_init, chain_id)
- genlayer.std.contract(t: type) type [source]#
Decorator that marks class as a contract
Note
There can be only one “contract” at address, so this function must be called at least once
- Return type:
- genlayer.std.contract_interface(_contr: GenVMContractDeclaration) Callable[[Address], GenVMContractProxy] [source]#
This decorator produces an “interface” for other GenVM contracts. It has no semantical value, but can be used for auto completion and type checks
@gl.contract_interface class MyContract: class View: def view_meth(self, i: int) -> int: ... class Write: def write_meth(self, i: int) -> None: ...
- genlayer.std.deploy_contract(*, code: bytes, args: Sequence[Any] = [], kwargs: Mapping[str, Any] = {}, **data: Unpack[DeploymentTransactionDataKwArgs]) Address | None [source]#
Function for deploying new genvm contracts
- genlayer.std.eq_principle_prompt_comparative(fn: Callable[[], Any], principle: str) str #
Comparative equivalence principle that utilizes NLP for verifying that results are equivalent
- Parameters:
- Return type:
Note
As leader results are encoded as calldata,
format()
is used for string representation. However, operating on strings by yourself is more safe in generalNote
supports
.lazy()
version, which will returnLazy
- genlayer.std.eq_principle_prompt_non_comparative(fn: Callable[[], str], *, task: str, criteria: str) str #
Non-comparative equivalence principle that must cover most common use cases
Both leader and validator finish their execution via NLP, that is used to perform
task
oninput
. Leader just executes this task, but the validator checks if task was performed with integrity. This principle is useful when task is subjectiveNote
supports
.lazy()
version, which will returnLazy
- Return type:
- genlayer.std.eq_principle_strict_eq(fn: Callable[[], T]) T #
Comparative equivalence principle that checks for strict equality
- Parameters:
fn (Callable[[], T]) – functions to perform an action
- Return type:
T
Note
supports
.lazy()
version, which will returnLazy
- genlayer.std.eth_contract(contr: EthContractDeclaration) Callable[[Address], EthContractProxy] #
- Return type:
- genlayer.std.exec_prompt(prompt: str, **config: Unpack[ExecPromptKwArgs]) str #
API to execute a prompt (perform NLP)
- Parameters:
prompt (
str
) – prompt itself**config (
ExecPromptKwArgs
) – configuration
- Return type:
str
Note
supports
.lazy()
version, which will returnLazy
- genlayer.std.get_webpage(url: str, **config: Unpack[GetWebpageKwArgs]) str #
API to get a webpage after rendering it
- Parameters:
url (
str
) – url of website**config (
GetWebpageKwArgs
) – configuration
- Return type:
str
Note
supports
.lazy()
version, which will returnLazy
- genlayer.std.message: MessageType = Ellipsis#
Represents fields from a transaction message that was sent
- genlayer.std.private(f)[source]#
Decorator that marks method as private. As all methods are private by default it does nothing.
- genlayer.std.rollback_immediate(reason: str) NoReturn [source]#
Performs an immediate rollback, current VM won’t be able to handle it, stack unwind will not happen
- Return type:
- genlayer.std.sandbox(data: Callable[[], Any]) Any #
Runs function in the sandbox
Warning
It returns result via pickle, which can be unsafe. If it is not desired wrap it to bytes yourself
Note
supports
.lazy()
version, which will returnLazy
- Return type:
- genlayer.std.calldata
This module is responsible for working with genvm calldata
Calldata supports following types:
Primitive types:
Composite types:
list
anddict
, as well ascollections.abc.Sequence
andcollections.abc.Mapping
#.
CalldataEncodable
#dataclasses
For full calldata specification see genvm repo
Proxy to module
genlayer.py.calldata
- genlayer.std.advanced
This module provides some “advanced” features that can be used for optimizations
If you are using something “advanced” you must know what you do
Proxy to module
genlayer.std.advanced
- genlayer.std.wasi
Proxy to module
genlayer.std._wasi