Skip to main content
Jupyter Notebooks are a document format that can include code, text, and other rich output. And with the appropriate setup they support Soroban Rust contracts. To use Soroban contracts in a Jupyter Notebook, the following setup is required. The following setup uses Visual Studio Code, but any Jupyter client and server can be used.
Rust support in Jupyter Notebooks is experimental. You might run into bugs, or unexpected behavior.

Getting Started

  1. Install Visual Studio Code (VSCode)
  2. Install the Jupyter Notebook extension in VSCode
  3. Install the evcxr Rust Jupyter kernel with:
  4. Run the Create: New Jupyter Notebook command in VSCode
  5. Click the Select Kernel button in the top right
  6. Select Jupyter Kernel...
  7. Select Rust by searching for Rust
  8. Enter on the first line an import of the soroban-sdk dependency with the testutils feature enabled.
  9. Enter a contract. For example:
  10. Enter some code to create a Soroban environment, register the contract, and invoke it.
  1. Click the play button to run the code.
Congratulations you have a Jupyter Notebook with contract code that should look something like the screenshot below, ready for hacking and experimenting.

Screenshot

A running Jupyter notebook

Community

Have ideas for how to improve Soroban contracts in Jupyter Notebooks? Join the community on Discord.