0) Prerequisites
- Python 3.10+ and pip installed
- A terminal on macOS/Linux/WSL (Windows PowerShell also works)
Tip: Use a virtual environment to keep dependencies isolated:
1) Create a project folder
2) Install the CLI
3) Add the WIT world
Createnewton-provider.wit in the project root:
4) Generate Python bindings
This produces awit_world package with types and imports for your WIT:
5) Implement your component logic
Createpy_bindings/app.py:
Note: Keep all imports at the top of the file; don’t import inside functions.
6) Build the component
From inside thepy_bindings/ directory, 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>
7) Next steps
-
Port the
op-simdirectory (in its entirety) from: op-sim GitHub into your project root. - Test your WASM binary by running op-sim: