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) 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.