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

Receive and Fallback

On the EVM target, the route names receive and fallback are reserved and lower to Solidity’s special functions of the same name.

Shape rules

Both routes must:

  • take no parameters;
  • declare no return type;
  • not be marked view or pure.

An entity may declare at most one receive and at most one fallback (V41). Shape violations are V40.

receive

Handles plain native-currency transfers with empty calldata (the usual ETH receiver). Write it with the required accept keyword so the generated function is payable:

entity EthVault {
    routes {
        accept receive() => [
            // credit balance via member transforms, emit, etc.
        ]
    }

    m_deposited: U256 {
        in receive() => m_deposited + msg::value
    }
}

Treat accept receive() as the language spelling of a payable ETH receiver — empty calldata, native value welcome. The generated Solidity is receive() external payable.

fallback

Runs when a call has no matching function selector (and is not a plain ETH send that hits receive):

entity EthVault {
    routes {
        accept receive() => []

        fallback() => [
            // optional catch-all
        ]
    }
}

fallback becomes payable automatically if (and only if) the body or its transforms read msg::value.