Understanding the Interpreter
Interactive Solidity execution in Wysdom notebooks
Wysdom notebooks bring the interactive power of Jupyter Notebooks to Web3 development. They allow you to write, test, and execute Solidity code instantly without deployment overhead. Think of it as a playground where you can experiment with Solidity in real-time.
What Makes It Special?
Unlike traditional Solidity development where you need to compile and deploy contracts, Wysdom notebooks let you:
- Write code line by line by writing statements rather than just contracts
- Get immediate results
- Skip semicolons (
;
) at the end of lines - Test ideas quickly without deployment costs
Statements vs. contracts
A statement is a piece of code that runs in a free-floating way, without being encapsulated in a contract:
A contract, on the other hand, is a container for state variables, functions, and other contract-related elements:
How does it work?
When writing a statement, underneath the hood we insert it into this base context depending on the scope.
There are three different scopes where statements can be inserted:
1. Source level scope
The highest level scope that includes interfaces
, libraries
, imports
, and contracts
.
would be inserted like this:
2. Contract level scope
Contract level scope includes state variables, events, and modifiers that are accessible throughout the contract.
is inserted in this way:
Key points about contract level scope:
- State variables persist between function calls
- Events can be emitted from any function
- Modifiers can be used by any function
- Constructor sets initial state
3. Function level scope
Function level scope includes local variables and parameters that only exist during function execution.
is inserted in this way:
Key points about function level scope:
- Can access and modify contract state variables
- Can emit events and use modifiers
- Parameters (
input
) are only accessible within the function - Block-scoped variables are only accessible within their block
Printing variables and calling function returns
Wysdom notebooks give you the ability to print variables and call function returns by omitting the semicolon ;
in the last line:
This will be run in the function scope of the base contract