Prerequisites
- Rust Toolchain
- Install Rust via rustup
- Version: 1.75.0 or later
- WASM Targets
- Required Tools
Project Structure
Step-by-Step Build Process
Step 1: Define the WIT Interface
Create a WIT file (wit/world.wit) compatible with Newton Protocol:
Step 2: Configure Cargo.toml
Set up yourCargo.toml for WASM component compilation:
Step 3: Implement the Rust Code
Insrc/lib.rs, generate bindings and implement your functionality:
Step 4: Build the WASM Component
Option A: Using cargo-component (Recommended)
Option B: Using standard cargo
Step 5: Validate the WASM Component
Step 6: Test your component
Use the Newton CLI to simulate your WASM data provider locally without deploying to the blockchain:<package_name> with your crate name and --input-json with your component’s expected input schema.
For more options, see the Newton CLI reference.