Vyper theorytheory 0/50 · 0%
Web3 integration · medium

22. Sending ETH: send, raw_call and default

Moving value out of a contract safely.

`send(to, amount)` forwards a small fixed gas stipend and reverts on failure — good for simple payouts. For calling arbitrary contracts with data or more gas, use `raw_call(to, data, value=amount)`.

@external
def withdraw():
    amount: uint256 = self.balances[msg.sender]
    self.balances[msg.sender] = 0
    send(msg.sender, amount)

@external
@payable
def __default__():
    pass

`__default__` is Vyper's fallback function — it runs when a call doesn't match any function selector, similar to Solidity's `fallback`/`receive`.

Check your understanding

  1. 1. What does `send(to, amount)` do on failure?

  2. 2. Which builtin lets you forward custom data and gas to another contract?

  3. 3. What is `__default__` equivalent to in Solidity?