@stuartwhite/cre-sdk-javy-plugin
v1.0.3
Published
Chainlink CRE SDK Javy Plugin.
Readme
@chainlink/cre-sdk-javy-plugin
WebAssembly compilation tools for Chainlink CRE SDK workflows using Javy.
This package enables compiling TypeScript/JavaScript workflows to WebAssembly for execution in the Chainlink Runtime Environment. It provides the Javy plugin that exposes CRE host functions to guest workflows.
Installation
bun add @chainlink/cre-sdk-javy-pluginQuick Start
Note: Most users will use the main @chainlink/cre-sdk package which includes compilation tools.
# Install the main SDK (includes this package)
bun add @chainlink/cre-sdk
# One-time setup: download Javy binary and compile plugin
bunx cre-setup
# Compile your workflow to WebAssembly
bunx cre-compile src/workflow.ts dist/workflow.wasmUsage
Standalone Usage
If using this package directly (without the main SDK):
Install the package
bun add @chainlink/cre-sdk-javy-pluginSetup (one-time)
bunx cre-setupThis downloads the appropriate Javy binary for your OS and compiles the CRE plugin.
Compile workflows
bunx cre-compile-workflow <input.js> <output.wasm>
Example
# With main SDK (typical usage)
bunx cre-compile src/hello-world.ts dist/hello-world.wasm
# Standalone (using this package directly)
bunx cre-compile-workflow src/hello-world.js dist/hello-world.wasmJavy Setup & Troubleshooting
macOS
The repo includes pre-compiled Javy binaries. If you encounter Apple security issues:
# Remove quarantine attribute
xattr -d com.apple.quarantine ./bin/javy-arm-macos-v5.0.4
# Make executable
chmod +x ./bin/javy-arm-macos-v5.0.4
# Verify installation
./bin/javy-arm-macos-v5.0.4 --versionLinux
# Make executable
chmod +x ./bin/javy-arm-linux-v5.0.4
# Verify installation
./bin/javy-arm-linux-v5.0.4 --versionPlugin Architecture
The Javy Chainlink SDK plugin exposes host functions to guest workflows:
- Static Linking: Plugin is compiled into the final WASM (current approach)
- Dynamic Loading: Runtime plugin discovery (future enhancement)
Build from Source
Prerequisites
- Rust toolchain with
wasm32-wasip1target - Bun >= 1.2.21
# Install Rust WASM target
rustup target add wasm32-wasip1
# Install wasm-tools for debugging
cargo install --locked wasm-toolsBuilding
# Build the plugin
bun run build
# Or manually build the Rust plugin
cd src/javy_chainlink_sdk
cargo build --target wasm32-wasip1 --releaseBuild Output
After building, you'll find:
dist/javy_chainlink_sdk.wasm- The compiled plugindist/workflow.wit- WebAssembly Interface Types definitions
Debugging Compiled WASM
Use wasm-tools to inspect compiled workflows:
# Validate a compiled workflow
wasm-tools component targets --world workflow src/workflow.wit dist/workflow.wasm
# Print WASM structure
wasm-tools print dist/workflow.wasmConfiguration
The plugin uses these configuration files:
src/javy_chainlink_sdk/Cargo.toml- Rust dependencies and build configsrc/workflow.wit- WebAssembly Interface Types for CRE workflowsbin/compile-workflow.ts- Workflow compilation logicbin/setup.ts- One-time setup script
Compatibility
- Javy Version: v5.0.4
- Rust Edition: 2021
- WASM Target:
wasm32-wasip1 - Node Runtime: Bun >= 1.2.21
Development
Project Structure
src/
├── javy_chainlink_sdk/ # Rust plugin source
│ ├── src/lib.rs # Plugin implementation
│ └── Cargo.toml # Rust dependencies
├── workflow.wit # WASM interface definitions
bin/
├── setup.ts # Setup script
└── compile-workflow.ts # Compilation scriptTesting
# Run plugin tests
cd src/javy_chainlink_sdk
cargo test
# Test compilation with example workflow (requires @chainlink/cre-sdk installed)
bunx cre-compile examples/hello-world.ts test-output.wasm
# Or with standalone binary
bunx cre-compile-workflow examples/hello-world.js test-output.wasmContributing
- Make changes to the Rust plugin in
src/javy_chainlink_sdk/ - Build and test:
bun run build - Test compilation:
bunx cre-compile <test-file> <output>orbunx cre-compile-workflow <test-file> <output> - Verify WASM output via simulating with CRE CLI.
License
See LICENSE in LICENSE.md
