Skip to main content

Rescueable

Git Source

Inherits: IRescueable, ERC165

Title: Rescueable

An abstract base for contracts that expose a privileged rescue() to sweep accidentally-sent assets. Derived contracts authorize the caller via the _authorizeRescue() hook.

The native asset is identified using the EIP-7528 sentinel.

Functions​

rescue​

Sweeps the entire balance of the specified asset to the provided recipient. Pass the EIP-7528 native sentinel (ERC7528Constants.NATIVE_ASSET) as token_ to rescue the native asset.

Reverts if:

  • The caller is not authorised by the implementation's _authorizeRescue().
  • to_ is the zero address.

Does NOT revert when the contract's balance of token_ is zero, so the call is a no-op in that case.

function rescue(address token_, address payable to_) public virtual override;

Parameters

NameTypeDescription
token_addressThe token to rescue, or the EIP-7528 native sentinel for the native asset.
to_address payableThe recipient of the rescued assets.

_authorizeRescue​

Hook for subclasses to authorize the caller of rescue().

Implementations MUST revert if the caller is not authorised.

function _authorizeRescue() internal view virtual;

supportsInterface​

See IERC165.

function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4

Returns

NameTypeDescription
<none>bool