Vyper theorytheory 0/50 · 0%
Functions · easy

8. Every function needs a visibility decorator

There is no implicit visibility — Vyper forces you to be explicit.

Unlike Solidity, where forgetting a visibility keyword silently defaults to `public`, Vyper simply refuses to compile a function without `@external` or `@internal`. This single rule has eliminated an entire historical class of Solidity bugs (accidentally public functions).

@external
def withdraw(amount: uint256):
    assert msg.sender == self.owner, "not owner"
    send(self.owner, amount)

You can stack multiple decorators on one function, e.g. `@external` with `@view`, `@payable`, or `@nonreentrant("lock")`, but the visibility decorator is always mandatory.

Check your understanding

  1. 1. What happens if you omit both @external and @internal?

  2. 2. Why does this design choice matter for security?

  3. 3. Can a function stack multiple decorators?