Call (Private Routes)
The call action invokes another route on the same entity. It is the way
to run a private route — a route intended only for internal use by the
entity’s other routes.
Syntax
call routeName(args)
Arguments must match the target route’s parameter list. There is no ~> or
return capture: call runs the private route for side effects (member
transforms and its action list) and continues with the caller route afterward.
Private routes
Declare a route with the private modifier:
entity Ledger {
routes {
publish(total: U256) => [
call apply_total(total)
]
private apply_total(total: U256) => []
}
m_total: U256 {
in apply_total(total) => total
}
}
| Target | Lowering |
|---|---|
| EVM | An internal Solidity function (_apply_total), called directly |
| Lean | Internal transition helper in generated modules |
Private routes still participate in member transforms (in apply_total(...)).
A private route is not part of the contract’s external interface, and call
is an ordinary in-contract call: msg::sender inside the private route is
the original caller.
Restrictions
| Allowed in caller | Forbidden |
|---|---|
Regular, init, phased routes | pure routes calling private (V11) |
call after sends, deploys, let | call with var capture (use ~> for return values) |
A view route may not call a route that has member transforms or
state-changing actions, directly or through further calls (V9).
When to use
private route + call splits one public entry point into internal steps —
shared checks, multi-step setup, or helper routes that only make sense inside
the entity. For shared computation without state changes, a
pure function is usually simpler.
For return values from another entity, use a typed send with var capture
(see Send Messages). For events, use Emit Events.