Skip to main content
Newton provides simulation endpoints and local tools at every layer of the stack. Use these to validate your policies, oracles, and integration before deploying to production.

Local Policy Simulation

Test Rego policy logic without the network using the Newton CLI:
newton-cli regorus eval \
  --policy policy.rego \
  --input '{"from":"0xAbC...","to":"0xDeF...","value":"0x0","data":"0x","chainId":"0xaa36a7","functionSignature":"0x"}' \
  --data '{"params":{"max_amount":"1000"},"data":{"eth_price_usd":2500}}'
This evaluates your Rego policy locally with full support for Newton crypto extensions (newton.crypto.ecdsa_recover_signer, newton.crypto.ecdsa_recover_signer_personal).

Local Oracle Simulation

Test your WASM data oracle without deploying:
newton-cli --chain-id 11155111 policy-data simulate \
  --wasm-file policy.wasm \
  --input-json '{"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18"}'
The CLI runs your WASM component in a sandboxed environment with the Newton HTTP host. The --input-json value is passed to your run function as the input string.

Gateway Simulation

Simulate a full policy evaluation via the Gateway RPC without any on-chain interaction:

Simulate a Task

Tests the complete evaluation pipeline (data oracle + policy) for a specific PolicyClient:
curl -X POST https://gateway-avs.sepolia.newt.foundation/rpc \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_api_key>" \
  -d '{
    "jsonrpc": "2.0",
    "method": "newt_simulateTask",
    "params": {
      "policy_client": "0xYourPolicyClientAddress",
      "intent": {
        "from": "0xCallerAddress",
        "to": "0xTargetAddress",
        "value": "0x0",
        "data": "0x",
        "chain_id": "0xaa36a7",
        "function_signature": "0x"
      }
    },
    "id": 1
  }'

Simulate Policy Only

Test Rego policy evaluation with provided inputs (no oracle execution):
curl -X POST https://gateway-avs.sepolia.newt.foundation/rpc \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_api_key>" \
  -d '{
    "jsonrpc": "2.0",
    "method": "newt_simulatePolicy",
    "params": {
      "policy_cid": "bafyrei...",
      "intent": { ... },
      "data": { "eth_price_usd": 2500 },
      "params": { "max_amount": "1000" }
    },
    "id": 1
  }'

Simulate PolicyData Only

Test a WASM oracle execution via the Gateway:
curl -X POST https://gateway-avs.sepolia.newt.foundation/rpc \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your_api_key>" \
  -d '{
    "jsonrpc": "2.0",
    "method": "newt_simulatePolicyData",
    "params": {
      "policy_data_cid": "bafyrei...",
      "input": "{\"address\":\"0x...\"}",
      "secrets": { "API_KEY": "sk-test-xxx" }
    },
    "id": 1
  }'

Newton Explorer

The Newton Explorer provides a visual interface for inspecting tasks, attestations, and policy evaluations on-chain. Use it to:
  • View task status and results
  • Inspect attestation details (signers, quorum, expiration)
  • Trace the evaluation flow from intent to on-chain verification

BLS Diagnostics

If an attestation fails on-chain verification, check:
CheckHow
Attestation expirationCompare attestation.expiration against current block number
Signer bitmapVerify the signer bitmap includes enough operators for quorum
Reference blockEnsure the reference block matches the operator set used for verification
Chain IDConfirm the intent’s chainId matches the chain where the PolicyClient is deployed

Debugging Patterns

SymptomLikely CauseDiagnostic Step
newt_simulateTask returns non-compliantPolicy logic rejects the intentRun newt_simulatePolicy with the same inputs to isolate the Rego evaluation
Oracle returns empty dataWASM run function error or HTTP fetch failureTest locally with newton-cli policy-data simulate
Attestation expires before on-chain submissionToo much time between evaluation and transactionReduce latency or increase the expiry_offset parameter
On-chain verification failsOperator set rotated or wrong chainCheck reference block and chain ID
TaskAlreadyExists errorDuplicate intent hashModify the intent nonce or wait for the existing task
Policy returns CAP instead of ALLOWIntent value exceeds policy thresholdCheck data.params values on your PolicyClient

SDK Debugging

Enable verbose logging in the Newton SDK:
import { createPublicClient, http } from 'viem';
import { sepolia } from 'viem/chains';
import { newtonPublicClientActions } from '@magicnewton/newton-protocol-sdk';

const client = createPublicClient({
  chain: sepolia,
  transport: http(),
}).extend(newtonPublicClientActions({
  apiKey: process.env.NEWTON_API_KEY!,
  gatewayUrl: 'https://gateway-avs.sepolia.newt.foundation/rpc',
}));

// Simulate first to debug
const simulation = await client.simulateTask({
  policyClient: '0xYourPolicyClientAddress',
  intent: { /* ... */ },
});

console.log('Simulation result:', JSON.stringify(simulation, null, 2));

Next Steps

Deployment Checklist

Pre-launch verification checklist

Error Reference

Complete error code reference