Refund a call

A call's price waits in escrow from the moment the call opens. When the enclave has not settled the call by its deadline, the whole price goes back to the caller. Nothing is charged for a call that was not answered.

When a call can be refunded#

A call has a deadline slot, set when it opens: the opening slot plus the protocol's call deadline (callDeadlineSlots in GET /v1/config). Until that slot the enclave can still settle it. After it, the call is refundable.

The call readsMeaning
open, refund state pending-deadlineThe deadline has not passed. The enclave can still answer.
refundableThe deadline has passed with no receipt. The escrow can be taken back.
refundedThe escrow is back with the caller.
settledThe call was answered and paid out. There is nothing to refund.

Take the refund#

Open /account with the wallet that made the call. Calls are listed with their state. Press Refund on a refundable call and approve the transaction. The call panel on the model's page offers the same button when the call it just made becomes refundable.

The transaction is refund_call. The escrow returns to the wallet that opened the call, whoever sends the transaction. For a price in a mint, the escrow's token account is closed and its rent returns to the caller as well.

Refunds nobody takes#

The protocol's crank sends refund_call for calls that pass their deadline, so an expired call is refunded without the caller doing anything. Taking the refund by hand is for a caller who wants it at once.

Failures#

ErrorMeaning
CALL_NOT_REFUNDABLEThe deadline has not passed.
CALL_NOT_OPENThe call settled or was refunded already.
CALL_NOT_FOUNDNo call has this address.

The mechanism is in Calls and receipts, the instruction in Program: Instructions.