0) Prerequisites
- Node.js 18+ and npm installed
- A terminal on macOS/Linux/WSL (Windows PowerShell also works)
Tip: Use nvm to manage Node versions:
1) Create a project folder
2) Install CLI
3) Add the WIT world
Createnewton-provider.wit in the project root:
4) Implement your component logic
Createapp.js:
Note: Keep this import at the top level of your module; ComponentizeJS resolves virtual specifiers like 'newton:provider/http@0.1.0' when you build the component.
5) Build the component
policy.wasm in the project root — a component that:
- Imports
newton:provider/http.fetchfrom the host - Exports
run(input: string) -> result<string, string>
6) (Alternative) Programmatic build
Createcomponentize.mjs:
7) Test your component
Use the Newton CLI to simulate your WASM data provider locally without deploying to the blockchain:--input-json value is passed directly to your component’s run function as the input string argument. Replace the example JSON with your own input schema.
For more options, see the Newton CLI reference.