Description

Scribe is a compact Yul transpiler written in Rust that targets the Polygon Miden VM. Scribe works by compiling Yul down to Miden opcodes, allowing developers to write smart contracts in Yul and run them on Polygon Miden. Since Yul is the intermediate language for Solidity, Vyper and Yul+, Scribe is a great foundation for various smart contract languages to compile code to run on Polygon Miden. Currently, Scribe is able to transpile Yul syntax including blocks, for loops, if statements, number literals, variable declarations, assignments, and function calls. We are still in the process of adding recognition for function definitions, break/continue, true literals, false literals, switch/case statements, leave statements, string literals and hex numbers.

Scribe showcase

How it's made

Scribe is built with Rust and uses the Pest parser to be able to recognize Yul Grammar. Here is a look under the hood at how Scribe translates a Yul contract to the Miden VM opcodes. First, the Yul contract is read in and converted to a string. Then the string is passed to the grammar parsing logic where Scribe looks for Yul statements, expressions and other grammar. Using these matches from Pest, we generate an abstract syntax tree consisting of structs and enums. This AST is then fed into the assembly generator where Scribe generates the corresponding Miden assembly for each node in the AST. The result is a list of Miden opcodes ready to run on the Miden VM! Through this process, Scribe enables fully functional Miden assembly to be generated from Yul contracts! Since languages like Solidity and Vyper compile to Yul before generating EVM opcodes, in future versions of Scribe, it will be possible to transpile code written in Solidity or Vyper into Miden assembly!