Codegen Mapping
How Cambrian constructs lower on the public targets.
Solidity-EVM (--target evm)
| Cambrian | Solidity |
|---|---|
entity E | Contract E (flat file under src/) |
| members | Storage variables (+ transforms inlined into route bodies) |
| routes | External / public functions |
view routes | view functions |
msg::sender / msg::value | msg.sender / msg.value (payable when value is read) |
~> dest typed send | External call |
deploy E(...) | Factory / CREATE2 when deterministic |
event / emit | Solidity event / emit |
error / throw Name | Custom errors / revert |
test / property / invariant | Foundry tests / fuzz / invariant handlers |
Lean-EVM (--target lean)
| Cambrian | Lean |
|---|---|
| entity state | Structure fields (plus ghost key lists for iterated maps when needed) |
| routes | Functions World → … (failing routes in an error monad / Except-style surface) |
| sends / deploys | World updates (call, occupancy, balances) |
property / test | Theorems in *Spec.lean |
invariant | Action / step / runTrace style definitions + checks |
Prefer reading a generated output tree for the exact file layout; lowering details evolve with each backend.