Package: michelson-kernel
Michelson kernelJupyter kernel for the Michelson languageFeaturesCustom interpreter with runtime type checkerSyntax highlighterAutocomplete byTabInplace docstrings byShift+TabMacros supportVerbose execution loggingDebug helpersHow to installOption 1: try online!Powered by awesome Binder:https://mybinder.org/v2/gh/baking-bad/michelson-kernel/binder?filepath=michelson_quickstart.ipynbOption 2: run in dockerGet the latest image from dockerhub (only when new releases are published)docker pull bakingbad/michelson-kernelCreate container using verified docker image:docker run --rm -it -p 127.0.0.1:8888:8888 -v $(pwd):/home/jupyter/notebooks bakingbad/michelson-kernelOpen the link from container output in your browserSave notebooks in the mapped folder in order not to loose themOption 3: install python packageRequires Python 3.5+. The recomended way to install it (especially if you plan to use multiple versions) ispyenv. Make sure you have allnecessary packetsinstalled. After that:pyenv install 3.7.0
pyenv local 3.7.0   # per folder
pyenv global 3.7.9  # per systemEnsure you have several crypto libraries installed (seepytezos docs):sudo apt install libsodium-dev libsecp256k1-dev libgmp-devInstall the package using pippip install michelson-kernelInstall Jupyterpip install jupyterCheck that Jupyter is now supporting Michelson kerneljupyter kernelspec listRun jupyterjupyter notebookOpen the link from the command output, create new notebook with Michelson kernel.Option 4: install from sourcesFollow steps 1-2 from "Option 3" to ensure you have correct Python version and packets required for the PyTezos libraryEnsure the following packages are installed:libssl-dev zlib1g-dev uuid-devGet the sources, build and installgit clone https://github.com/baking-bad/michelson-kernel
cd michelson-kernel
makeFollow steps 4-6 from "Option 3"How to uninstallRun the following commandjupyter kernelspec uninstall michelson -fCheck that Jupyter is no longer supporting Michelson kerneljupyter kernelspec listUninstall Python packagepip uninstall michelson-kernelHow it worksTechnical details of the REPL implementationhttps://forum.tezosagora.org/t/michelson-repl-in-a-jupyter-notebook/1749Interactive tutorial demonstrating REPL featureshttps://mybinder.org/v2/gh/baking-bad/michelson-kernel/binder?filepath=michelson_quickstart.ipynbSame, but a rendered versionhttps://nbviewer.jupyter.org/github/baking-bad/michelson-kernel/blob/binder/michelson_quickstart.ipynbSample notebooksLocated in the current repository in a separate branch:https://github.com/baking-bad/michelson-kernel/tree/binderList of helpersThese instructions are not Michelson primitives and thus cannot be used outside of the Jupyter.In the Jupyter editor helpers are highlighted in blue.DUMPReturns the whole stack with values, types, and annotations if any.DUMP nReturns topnitems from the stack.PRINT "fmt"Prints a formatted string to the stdout, referencing arbitrary stack elements is allowed:PRINT "This is the top element {0}, and this is the second {1}"DROP_ALLClears the stack.EXPAND { code }Expands Michelson macros:EXPAND { PAPAIIR }INCLUDE pathLoads Michelson source from the filesystem (absolute or relative path)INCLUDE "test.tz", or from one of the Tezos networksINCLUDE "mainnet:KT1VG2WtYdSWz5E7chTeAdDPZNy2MpP8pTfL". Initializesparameter,storage, andcodesections. If loaded from the network, current storage is also written to theSTORAGEvariable and can be accessed later.PATCH prim valueSets value for on of the context-dependent Michelson instructions:AMOUNT,BALANCE,NOW,SOURCE,SENDER,CHAIN_ID.DEBUG boolEnables or disables verbose output:DEBUG FalseorDEBUG True.BIG_MAP_DIFFTakes the top of the stack, searches for temporarybig_mapinstances in that element, and displays what the big_map_diff would be like if it was a contract execution ending.BEGIN %entrypoint (param_expr) (storage_expr)Simulates the contract execution beginning. Requiresparameterandstoragesections initialized. Also, clears the stack.The%entrypointargument can be omitted,%defaultwill be used in that case.This helper also allocates temporary big_map instances if any in parameters or storage.You can useSTORAGEvariable for thestorage_expr, in case you have previously loaded it from the network.COMMITSimulates the contract execution ending. Requires aPairof operation list and valid storage on top of the stack. Returns a list of internal operations, new storage, and big_map_diff.RESETClears the stack, deletes all big_map instances.RESET "network"Does the same as the version without parameters, but also initializesNETWORKandCHAIN_IDvariables.Can be used to set real network context in order to access blockchain data.RUN %entrypoint (param_expr) (storage_expr)Requirescodesection initializes. Internally callsBEGIN, then executescode, and finishes withCOMMIT.Check out the articles and tutorial for more technical details, also you can take a look at theimplementation.ContactTelegram chat:@baking_bad_chatSlack channel:#baking-badCreditsThis project is supported by Tezos FoundationMichelson test set from the Tezos repo is used to ensure the interpreter workabilityMichelson structured documentation by Nomadic Labs is used for inline help