Base · 8453

How-To & Examples

recipes · 12 examples

Practical recipes for common NWO-ASM workflows. Every example is self-contained — copy, save as a .nwo file, run nwo-asm build, and you've got something working. Local-only recipes require no credentials.

Want help? Open the terminal and type setup for a guided walkthrough, or troubleshoot for common fixes.
Workflow

The three-line loop

Every NWO-ASM workflow reduces to three commands. Anything more advanced is a flag on one of these.

01 · WRITE nwo-asm new my-app scaffolds project + .nwo 02 · BUILD nwo-asm build lower + optimize + emit 03 · DISPATCH nwo-asm dispatch simulate · or live WRITE → BUILD → DISPATCH · ADD --DRY-RUN TO 03 FOR NO-COST SIMULATION
Recipes

Twelve worked examples

Every example below is real, runnable code. Click any to expand. Tagged by skill level and what they touch.

01

Hello, process matrix

Smallest possible NWO-ASM program: declare a module, hold a 1-qubit identity matrix, emit. CPU-only. No credentials.

module hello {
  output r : pmx[1]
  r = pmx.identity()
}
02

Anomaly score on a signal

Read a NumPy array, score it with the free-energy bound, print the result. Runs locally on CPU.

use metastate.anomaly
module ascore {
  input  s : f32[N]
  output v : f32
  v = anomaly.score(s)
}
03

Closed-form fit (eml)

Fit a symbolic expression to data — useful when you'd rather hold a small equation than a giant tensor.

use metastate.symbolic
module fit {
  input  xs : f32[N]
  input  ys : f32[N]
  output e  : expr
  e = symbolic.regress(xs, ys)
}
04

Route to QPU (with classical fallback)

Build a 2-qubit process matrix and route it through MetaState; QPU if available, GPU if not.

use metastate.quantum
module qroute {
  input  e : expr
  output h : handle
  h = quantum.route(pmx.lift(e), {
    prefer:   qpu,
    fallback: gpu,
  })
}
05

Proof of Inference

Have the substrate re-verify your inference and return a signed proof. Auditable by anyone.

use metastate.poi
module verify {
  input  h : handle
  output p : proof
  p = poi.verify(h)               # signed (PQC)
}
06

Anchor a proof on Base

Prepare the calldata that settles through the existing splitter — 35/35/30, plus 15% to your affiliate if set.

use metastate.anchor
module settle {
  input  p : proof
  output c : calldata
  c = anchor.prepare(p, usdc(base))   # no new contract
}
07

Dry-run before spending

Simulate the full dispatch locally to see expected cost and routing without touching any backend.

nwo-asm dispatch app.qasm3 --dry-run --explain

  → would route to: qpu (origin_wukong, expected 42ms)
  → estimated cost: $0.0008 USDC
  → no on-chain calls executed
08

Contribute GPU and earn

Run the nwo-agi client and let the network rent your idle GPU. Earns USDC paid through the same splitter.

# one-liner install
pip install nwo-agi
nwo-agi start --wallet 0xYourBaseAddress

  → node registered: NODE-0xC7…2A
  → accepting tasks · health 100%
09

Open a Portal from the terminal

Use the built-in terminal to bind a Portal to a wallet and watch its live metrics.

# inside the NWO ASM Terminal
nwo> portal.new qpu
  → opened PRT-0x5C41 on qpu · per-call USDC

nwo> portal.health PRT-0x5C41
  → PRT-0x5C41 · health 100% · latency 21ms · throughput 2.4 M/s
10

Set an affiliate address

Earn 15% of every call routed through a link you share. Configure once in nwo-asm.toml; payouts are on-chain.

[settlement]
affiliate = "0xYourBaseAddress"     # 15% of every settled call
11

Sign a build for provenance

Attach a CRYSTALS-Dilithium signature so consumers can verify the artifact you produced.

nwo-asm build app.nwo --sign

  → app.qasm3
  → app.qasm3.sig    (dilithium3, key ~/.nwo-asm/keys/identity)
12

Embed in Rust

Use NWO-ASM from inside a Rust app — same compiler, same dispatch, same settlement.

use nwo_asm::{Compile, Dispatch};
use metastate_client::Base;

let art = Compile::build("signal.nwo")?;
let res = Dispatch::new(art)
    .target("qpu")
    .settle(Base::usdc())
    .send()?;
println!("proof: {}", res.proof);
Tips

A few patterns worth knowing

Set a budget

The optimizer can run forever finding placements. budget_ms = 800 in config caps it; deterministic builds get a fixed budget.

Always dry-run first

Before paying for a live dispatch, use --dry-run --explain. It prints the placement, the proof, and the expected USDC cost — without spending anything.

Pin a backend

Override the optimizer when you need reproducibility: --backend qpu:origin_wukong. The build still verifies that backend can host your IR.

Use the keychain

Store secrets in your OS keychain instead of .env: nwo-asm key store IBM_QUANTUM_TOKEN. The toolchain reads it transparently.

Tech stack

What the recipes use

LayerTechNotes
LanguageNWO-ASM source · process matrices · causal coherenceMIT-licensed, embeddable.
CLInwo-asm binary · subcommands: new · build · dispatch · key · doctorSelf-contained.
LibraryRust crate nwo-asm · client crate metastate-clientFor embedded use.
SubstrateMetaState endpoints · A2A Agent CardLive; opt-in.
Compute meshnwo-agi client (Python)Optional; earn by contributing GPU.
SettlementMetaStateSplitter on Base 8453Existing audited contract; no new deploy.
Open terminal Portals dashboard Architecture