From Clause
The from clause restricts who may invoke a route by checking
msg::sender against an expected entity (or address) identity.
On EVM this lowers to a require(msg.sender == …) style guard.
Syntax
credit(account: address, amount: U256)
from Shop(m_shop_id) : throw Unauthorized()
=> []
The optional : throw ErrorName(...) supplies a named custom error when the
sender check fails (see Custom Errors).
Multiple senders
Join alternatives with | (OR):
update_price(asset: String, price: U256)
from Oracle(m_oracle_id) | Admin(m_admin_id) : throw Unauthorized()
=> []
From with where
from runs before where:
execute_trade(amount: U256)
from Broker(m_broker_id) : throw Unauthorized()
where amount > 0 : throw ZeroAmount()
&& m_status == Status::Active : throw Paused()
=> []
EVM arity rules (V33)
from Entity(...) takes as many arguments as the target entity has
identity members (zero for singletons: from Registry()).
extern entity targets skip V33. Plain address members used as senders
can also be compared with where msg::sender == m_owner when you do not need
entity-typed address prediction.
On EVM, from Entity(args) compares msg.sender to the same
CREATE2 expression as Entity.address(args), so authentication and addressing
stay in sync. See Deterministic Addresses.
When to use from
| Scenario | Prefer |
|---|---|
| Public caller actions | No from (or where on msg::sender) |
| Callbacks from a known Cambrian entity | from Entity(…) |
| Admin / oracle entities with predicted addresses | from Entity(…) on EVM |
| Plain address stored in a member | where msg::sender == m_owner |
where msg::sender == m_owner : throw Unauthorized()