Receive Function
1 min read
Pronunciation
[ri-seev fungk-shun]
Analogy
The receive function is like a mailbox slot that only accepts letters (Ether) but ignores packages (data‑bearing calls).
Definition
Key Points Intro
Receive functions handle direct Ether transfers through:
Key Points
Signature: `receive() external payable` only.
Empty calldata: Triggered when no data is sent.
Fallback precedence: Called before fallback if defined.
No arguments/return: Cannot process data or return values.
Example
A vault contract uses `receive() external payable { balances[msg.sender] += msg.value; }` to credit deposits automatically.
Technical Deep Dive
Security Warning
Unbounded logic in `receive()` can lead to denial‑of‑service if gas runs out; keep operations simple.
Caveat
Only triggers on empty calldata; calls with data still invoke fallback.
Receive Function - Related Articles
No related articles for this term.