Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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)

FieldTypeDescriptionSolidity lowering
msg::senderaddressCaller of this callmsg.sender
msg::valueintegerNative currency attached to the callmsg.value

These are the fields you should rely on for access control and payable logic.

Optional time alias

FieldNotes
msg::timestampLowers 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

ContextExample
Where clauseswhere msg::sender == m_owner : throw Unauthorized()
Route actions~> msg::sender with { value: amount }
Member transformsin deposit() => msg::value
Macrosmacro is_owner() -> bool = { msg::sender == m_owner }

For block / chain / balance environment reads, see System Context.