As the XRPL moves toward permissionless programmability, starting with Smart Escrows, it needs a secure, reliable, and high-performance engine to run custom developer code. The conclusion we came to is that that engine should be WebAssembly, often abbreviated as WASM.
Earlier this year, the RippleX Programmability team surveyed various virtual machine (VM) options, and concluded that WASM was the best choice for the XRPL ecosystem for a few different reasons. Read more here: https://dev.to/ripplexdev/a-survey-of-vms-for-xrpl-programmability-eoa
WASM is not exclusive to the blockchain world. It’s a universal, open standard that was originally designed to run high-performance applications in web browsers (though now it is used in many other contexts as well). It is intended to support any language on any operating system, and in practice most languages have some level of support. https://webassembly.org/
WASM-based smart contract runtimes are deterministic, secure, and portable. The entire system relies on WebAssembly's core promise of deterministic execution, meaning the code will run identically on all rippled nodes, regardless of operating system or hardware, to ensure consensus is maintained. In addition, WASM promises better performance, and supports many general-purpose programming languages, like Rust, C, and Go (in other words, a Web2 developer may not have to learn a new language). With those benefits, WASM is the most popular smart contract language choice of many of the newer blockchain projects, such as Polkadot, Cosmos, Near, and most recently Soroban on Stellar.
Host Functions
To securely access ledger data and improve the efficiency of computation-intensive tasks, the WASM code relies on Host Functions. Think of a Host Function as an internal API call: it is expressed outside the WASM code (in the efficient C++ code that runs the XRPL) and allows the WASM program to securely query data from the ledger state. In EVM terms, this is roughly equivalent to precompiles.
The fundamental rule for the WASM code in Smart Escrows is read-only access, with only very specific write access allowed. WASM code has read-only access to all ledger objects and a variety of other on-chain data (such as ledger header information). It only has write access to the Data field in the Escrow that it is attached to. This strict limitation ensures that the custom logic cannot negatively affect the integrity of the ledger or the balances of other accounts.
WASM runtime environments are low-level virtual stack machines, like JVM, and can be embedded into any host application (such as rippled). There are several different implementations, with various tradeoffs. We chose Wasmi due to its performance and history of use in other blockchains (Polkadot and Solana also use Wasmi). https://dev.to/ripplexdev/xrpl-programmability-wasm-runtime-revisit-2ak0
In summary, WASM is the secure, high-performance virtual machine that executes the custom release logic for Smart Escrows. It allows developers to deploy complex, conditional rules using familiar programming languages, all while operating within carefully guarded boundaries that ensure the security and stability the XRPL is known for.



Top comments (0)