Meet the Tech:
Payable Endpoints 🧩
The compile-time mechanism for accepting EGLD or ESDT payments at a contract endpoint.
The annotation declares the intent. self.call_value() reads what came in.
💡 🧵
How it works:
#[payable]
#[endpoint]
fn deposit(&self) {
let payment = self.call_value().single();
}
Without #[payable], any incoming payment causes the endpoint to fail before it runs.
Mark the endpoint with #[payable] to accept payments. Read what was sent with self.call_value().
.single() returns exactly one payment — EGLD or ESDT. Panics if zero or more than one came in.