TypeScript Runtime Environment

Your TypeScript workflows are compiled to WebAssembly (WASM) to run in the CRE execution environment. Understanding this compilation process helps you write compatible code and avoid common pitfalls.

How TypeScript becomes WASM

CRE uses Javy to compile your TypeScript workflows into WASM binaries. The compilation pipeline works as follows:

  1. TypeScript → JavaScript: Your .ts files are transpiled to JavaScript
  2. JavaScript → WASM: Javy bundles the JavaScript code with an embedded QuickJS engine into a WASM binary
  3. Execution: The WASM binary runs in the CRE runtime environment

QuickJS vs Node.js

Javy uses QuickJS, a lightweight JavaScript engine embedded in the WASM binary. QuickJS is not Node.js—it provides core JavaScript (ECMAScript) functionality but does not include the full Node.js API surface.

What is supported:

  • Standard JavaScript features like Map, Set, and most ES6+ syntax are fully supported
  • All CRE SDK capabilities, including EVM client, HTTP client, and consensus functions

Key limitation:

Not all Node.js built-in modules are available. For example, node:crypto is not supported. Before using third-party NPM packages, verify they don't rely on unsupported Node.js APIs.

Checking library compatibility

Before using third-party NPM packages in your workflows, verify they don't rely on unsupported Node.js APIs. The QuickJS Node.js compatibility documentation lists which Node.js modules are available.

The best way to verify compatibility is to test with cre workflow simulate. Simulation runs your workflow in the same WASM environment as production, so any compatibility issues should surface during simulation.

Extending with Rust

When a library you need doesn't work in QuickJS, or you need performance beyond what interpreted JavaScript in WASM can provide, you can inject a custom Rust crate into the plugin layer that bridges your TypeScript to the CRE runtime. The compiled Rust code runs natively within the same WASM binary as your workflow and is exposed as a typed global you call from TypeScript.

See Custom Rust Plugins for a full guide, including prerequisites, both prebuilt and source-extension modes, and step-by-step testing instructions.

Why WASM?

WebAssembly provides several benefits for CRE workflows:

  • Sandboxed execution: WASM runs in an isolated environment, providing security boundaries between your workflow code and the CRE runtime
  • Deterministic execution: WASM ensures workflows produce consistent results across different nodes in the DON
  • Performance: WASM binaries are compact and execute efficiently

Get the latest Chainlink content straight to your inbox.