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
- Returns:
object supporting
.name(*args, **kwargs)
that emits a message and returnsNone
- emit_transfer(**data: Unpack[TransactionDataKwArgs])[source]#
Method to emit a message that transfers native tokens
- class genlayer.std.MessageType[source]#
Bases:
NamedTuple
MessageType(contract_address, sender_address, origin_address, value, is_init, chain_id)
- 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
- Parameters:
- Returns:
address of new contract iff non-zero
salt_nonce
was provided- Return type:
Address | None
- genlayer.std.eq_principle_prompt_comparative(fn: Callable[[], Any], principle: str) str [source]#
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 [source]#
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 [source]#
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: ContractDeclaration) Callable[[Address], ContractProxy] #
- Return type:
- genlayer.std.exec_prompt(prompt: str, **config: Unpack[ExecPromptKwArgs]) str [source]#
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 [source]#
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.
- class genlayer.std.public[source]#
Bases:
object
- write = <genlayer.std._write object>#
Decorator that marks a contract method as a public write. Has .payable
@gl.public.write def foo(self) -> None: ... @gl.public.write.payable def bar(self) -> None: ...
- Return type:
T
- 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.calldata
This module is responsible for working with genvm calldata
Calldata natively supports following types:
Primitive types:
Composite types:
list
(and any othercollections.abc.Sequence
)dict
withstr
keys (and any othercollections.abc.Mapping
withstr
keys)
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
Warning
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