Summary: Fast-Track Cardano Development – Introducing the Scalus In-Memory Emulator
In the 55th edition of the Developer Office Hours, host Darlisa Consoni from the Cardano Foundation speaks with Alex Nemish and Serhii Lekariev about the new Scalus in-memory emulator. This tool is designed to significantly simplify and speed up testing and development for DApps and smart contracts on Cardano across JVM, JavaScript, and TypeScript environments.
The Problem: Slow feedback loops during testing
Testing smart contracts and transactions often takes a lot of time. However, developers need very fast feedback loops to program efficiently and detect errors immediately.
The Solution: The Scalus in-memory emulator
The emulator is a lightweight node that runs directly as a library in memory and requires no network-based API. Developers can submit transactions and query UTXOs, yielding instant results. It implements the Cardano ledger rules, with the exception of governance functions and staking rewards.
Cross-platform compatibility (JVM, JavaScript, and TypeScript)
Since Scalus is written in Scala, it is natively compatible with all JVM languages, such as Java and Kotlin. Thanks to Scala.js, the emulator is also exported as a library for JavaScript. A corresponding npm package with TypeScript bindings allows for seamless use in web-based projects.
Seamless integration and flexibility
A major advantage is that developers only need to write their tests once. By changing environment variables, the exact same test code can be run against the ultra-fast in-memory emulator, the Yaci Dev Kit, a preprod testnet, or the mainnet. Scalus can even automatically start the Yaci Dev Kit as a Docker container in the background, run the tests, and shut it down again. Furthermore, the emulator can be easily integrated into existing libraries like MeshJS and the Evolution SDK.
Next steps and roadmap
The team is currently focusing on optimizations for data type representation. This enables a more efficient representation of data (such as maps, lists, or primitive values) within smart contracts, making them perform better. Additionally, they are working on improving test coverage, adding new examples, and expanding the standard library.
Top Five Q&A (FAQ) about the Scalus In-Memory Emulator
Question 1: What exactly is the Scalus in-memory emulator?
Answer: It is a lightweight Cardano node that runs directly in memory as a library. It allows developers to test transactions and query UTXOs without relying on network confirmations or external transport APIs, which drastically reduces development time.
Question 2: Which programming languages does Scalus support?
Answer: Because the tool was developed in Scala, it is natively compatible with all JVM languages, such as Java and Kotlin. Additionally, it is exported for JavaScript via Scala.js and offers TypeScript bindings through an npm package.
Question 3: Does the emulator support all Cardano ledger rules?
Answer: The emulator supports most ledger rules and phase validations (such as double-spend checks), with one exception: governance and staking rewards are not integrated. However, techniques like the “withdraw zero” approach are fully supported.
Question 4: How does the emulator compare to the Yaci Dev Kit or a testnet?
Answer: The emulator provides the fastest feedback loop because it runs directly as a local library without spinning up external containers. However, a massive advantage of Scalus is that the exact same test code can be flexibly executed against the emulator, the Yaci Dev Kit, or a testnet. Scalus even automates starting and stopping the Yaci Dev Kit Docker container.
Question 5: What is next on the roadmap for the Scalus team?
Answer: The team is currently primarily working on optimizations for data type representation to make the execution of smart contracts even more efficient. Moreover, they are focusing on expanding test coverage, adding code examples, and enhancing the standard library.