Michelson REPL
Interpreter
- class pymavryk.michelson.repl.Interpreter(extra_primitives: List[str] | None = None, debug: bool = False)[source]
Michelson interpreter reimplemented in Python. Based on the following reference: https://tezos.gitlab.io/michelson-reference/
- execute(code: str) InterpreterResult [source]
Execute some code preserving current context and stack
- Parameters:
code – Michelson code
- static run_callback(entrypoint: str, parameter, storage, context: ExecutionContext) Tuple[Any, Any, List[str], Exception | None] [source]
Execute view entrypoint of the contract loaded into the context
- Parameters:
entrypoint – contract entrypoint
parameter – parameter section
storage – storage section
context – execution context
- Returns:
[operations, storage, stdout, error]
- static run_code(parameter, storage, script: str, entrypoint='default', output_mode='readable', amount=None, chain_id=None, source=None, sender=None, balance=None, block_id=None, **kwargs) Tuple[List[dict], Any, List[dict], List[str], Exception | None] [source]
Execute contract in interpreter
- Parameters:
parameter – parameter expression
storage – storage expression
script – contract’s Michelson code
entrypoint – contract entrypoint
output_mode – one of readable/optimized/legacy_optimized
amount – patch AMOUNT
chain_id – patch CHAIN_ID
source – patch SOURCE
sender – patch SENDER
balance – patch BALANCE
block_id – set block ID
- static run_tzt(script: str, amount=None, chain_id=None, source=None, sender=None, balance=None, block_id=None, **kwargs) None [source]
Execute TZT test suite code
- Parameters:
script – test contract’s Michelson code
amount – patch AMOUNT
chain_id – patch CHAIN_ID
source – patch SOURCE
sender – patch SENDER
balance – patch BALANCE
block_id – set block ID
- static run_view(name: str, parameter, storage, context: ExecutionContext) Tuple[Any, Any, Exception | None] [source]
- class pymavryk.michelson.repl.InterpreterResult(*, stdout: List[str], error: Exception | None = None, instructions: MichelineSequence | None = None, stack: MichelsonStack | None = None)[source]
Result of running contract in interpreter
- error: Exception | None
- instructions: MichelineSequence | None
- lazy_diff = None
- operations = None
- stack: MichelsonStack | None
- stdout: List[str]
- storage = None
Michelson stack
- class pymavryk.michelson.stack.MichelsonStack(items: List[MichelsonType] | None = None)[source]
-
- dump(count: int) List[MichelsonType] | None [source]
- classmethod from_items(items: List[MichelsonType]) MichelsonStack [source]
- peek() MichelsonType [source]
- pop(count: int) List[MichelsonType] [source]
- pop1() MichelsonType [source]
- pop2() Tuple[MichelsonType, MichelsonType] [source]
- pop3() Tuple[MichelsonType, MichelsonType, MichelsonType] [source]
- push(item: MichelsonType)[source]
Execution context
- class pymavryk.context.impl.ExecutionContext(amount=None, chain_id=None, protocol=None, source=None, sender=None, balance=None, block_id=None, now=None, level=None, voting_power=None, total_voting_power=None, min_block_time=None, key=None, shell=None, address=None, counter=None, script=None, tzt=False, mode=None, ipfs_gateway=None, global_constants=None, view_results=None)[source]
-
- register_global_constant(expression)[source]
Register global constant :param expression: Micheline expression
- resolve_global_constants(expression)[source]
Replace global constants with their respectful values or throw an error if the constant is not defined :param expression: Micheline expression
- property sandboxed: bool
- property script: dict | None