Message Context (msg::)
The msg:: namespace describes the inbound call that triggered the current
route. Values are available in route actions, where / from clauses,
macros, and member transforms — not in pure fn or pure routes.
Primary fields (EVM)
| Field | Type | Description | Solidity lowering |
|---|---|---|---|
msg::sender | address | Caller of this call | msg.sender |
msg::value | integer | Native currency attached to the call | msg.value |
These are the fields you should rely on for access control and payable logic.
Optional time alias
| Field | Notes |
|---|---|
msg::timestamp | Lowers to block.timestamp on EVM. Prefer sys::now / sys::timestamp when you mean block time, so message context and system context stay distinct. |
msg::sender
macro is_owner() -> bool = {
msg::sender == m_owner
}
routes {
withdraw(amount: U256)
where msg::sender == m_owner : throw Unauthorized()
=> [
~> msg::sender with { value: amount }
]
}
In transforms:
m_last_caller: address {
in deposit(_) => msg::sender
}
m_balances: HashMap<address, U256> {
in deposit(amount) => {
let current = m_balances.get(msg::sender).unwrap_or(0);
m_balances.set(msg::sender, current + amount)
}
}
msg::value
routes {
deposit()
where msg::value > 0 : throw ZeroDeposit()
=> []
}
m_balance: U256 {
in deposit() => m_balance + msg::value
}
Routes (or transforms) that read msg::value are treated as payable on EVM so
callers can attach native currency.
Usage contexts
| Context | Example |
|---|---|
| Where clauses | where msg::sender == m_owner : throw Unauthorized() |
| Route actions | ~> msg::sender with { value: amount } |
| Member transforms | in deposit() => msg::value |
| Macros | macro is_owner() -> bool = { msg::sender == m_owner } |
For block / chain / balance environment reads, see System Context.