Data oracles are WebAssembly (WASM) components that fetch or compute external data at evaluation time. The Newton network executes your WASM, and the output is fed into your Rego policy asDocumentation Index
Fetch the complete documentation index at: https://docs.newton.xyz/llms.txt
Use this file to discover all available pages before exploring further.
data.data.
What is a Data Oracle?
A data oracle is a JavaScript (or Rust/Python) program compiled to WASM that:- Receives input arguments (
wasm_args) as a JSON string - Optionally fetches external data via HTTP
- Returns a JSON string that becomes available to your Rego policy as
data.data
WIT Interface
Every data oracle implements thenewton-provider WIT (WebAssembly Interface Types) contract. Create newton-provider.wit:
http import provides the fetch function for making HTTP requests from within the WASM sandbox. The run export is your oracle’s entry point.
Implement in JavaScript
Createpolicy.js:
The
httpFetch function is provided by the Newton WASM runtime — you do not need to import it. It maps to the http.fetch function defined in the WIT interface.Build WASM
Compile the JavaScript into a WASM component usingjco:
policy.wasm in the current directory.
If you installed
jco locally (without -g), run it via npx jco componentize ... instead.Test Locally
Test your WASM oracle before deploying:Alternative Languages
While JavaScript is the most common choice, you can also write data oracles in:- Rust — see the Rust WASM Guide
- Python — see the Python WASM Guide
Next Steps
Writing Policies
Write a Rego policy that uses your oracle’s output
Deploying with CLI
Deploy your oracle and policy to IPFS and on-chain