Package genlayer.std.genvm_contracts#

Warning

This is an internal module

class genlayer.std.genvm_contracts.ContractAt[source]#

Provides a way to call view methods and send transactions to GenVM contracts

__init__(addr: Address)[source]#
address: Address#

Address to which this proxy points

emit(**data: Unpack[TransactionDataKwArgs])[source]#

Namespace with write message

Returns:

object supporting .name(*args, **kwargs) that emits a message and returns None

emit_transfer(**data: Unpack[TransactionDataKwArgs])[source]#

Method to emit a message that transfers native tokens

view()[source]#

Namespace with all view methods

Returns:

object supporting .name(*args, **kwargs) that calls a contract and returns its result (Any) or rises its Rollback

Note

supports name.lazy(*args, **kwargs) call version

class genlayer.std.genvm_contracts.DeploymentTransactionDataKwArgs[source]#

Class for representing parameters of deploy_contract

salt_nonce: NotRequired[u256 | Literal[0]]#

iff it is provided and does not equal to \(0\) then Address of deployed contract will be known ahead of time. It will depend on this field

class genlayer.std.genvm_contracts.TransactionDataKwArgs[source]#

Built-in parameters of all transaction messages that a contract can emit

Warning

parameters are subject to change!

genlayer.std.genvm_contracts.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: ...
Return type:

Callable[[Address], GenVMContractProxy]

genlayer.std.genvm_contracts.deploy_contract(*, code: bytes, args: Sequence[Any] = [], kwargs: Mapping[str, Any] = {}) None[source]#
genlayer.std.genvm_contracts.deploy_contract(*, code: bytes, args: Sequence[Any] = [], kwargs: Mapping[str, Any] = {}, salt_nonce: Literal[0], **rest: Unpack[TransactionDataKwArgs]) None
genlayer.std.genvm_contracts.deploy_contract(*, code: bytes, args: Sequence[Any] = [], kwargs: Mapping[str, Any] = {}, salt_nonce: u256, **rest: Unpack[TransactionDataKwArgs]) Address

Function for deploying new genvm contracts

Parameters:
  • code – code (i.e. contents of a python file) of the contract

  • args – arguments to be encoded into calldata

  • kwargs – keyword arguments to be encoded into calldata

Returns:

address of new contract iff non-zero salt_nonce was provided