- Deterministic: the same code with the same input always gives the same result.
- Ahead-of-time (AOT) compilation: Baretta can compile code to native code before it runs, and it saves the compiled code in a persistent cache.
- Controlled execution: the Baretta runtime and its defined execution rules always govern how code runs.
How it works
1
Write Python code
Write your smart contract in Python, following the Baretta Rules.
2
Compile to Python bytecode
Your code is compiled to Python bytecode instructions.
3
Translate to the Baretta ISA
The instructions are translated to the Baretta instruction set (ISA). This ISA is static.
4
Compile with the Baretta AOT compiler
The Baretta AOT compiler turns the static ISA instructions into an executable object.
5
Run with the Baretta runtime
The Baretta runtime runs the executable object.
Why Python?
Python is easy to read and easy to learn. Even beginners can pick it up quickly, so more people can write smart contracts without learning a new language first.What is different from normal Python?
The main difference is the coding style. You may need a little time to adjust. These pages explain the changes:- Data types: Baretta supports a limited set of types.
- Baretta Rules: types must be declared, and pointers are available.
- Lists and dicts: collections hold one type of value.
- Lookup: how errors are handled.