SafeCall

Git Source

Library for performing safe calls to the recipients. Inspired by https://github.com/nomad-xyz/ExcessivelySafeCall

Functions

safeCall

Performs a call to the recipient using the provided gas limit, msg.value and payload in a safe way:

  • If the recipient is not a contract, false is returned instead of reverting.
  • If the recipient call reverts for any reason, false is returned instead of reverting.
  • If the recipient call succeeds, true is returned, and any returned data is ignored.
function safeCall(address recipient, uint256 gasLimit, uint256 msgValue, bytes memory payload)
    internal
    returns (bool success);

Parameters

NameTypeDescription
recipientaddressThe recipient of the call
gasLimituint256The gas limit to use for the call
msgValueuint256The msg.value to use for the call
payloadbytesThe payload to use for the call

Returns

NameTypeDescription
successboolTrue if the call succeeded, false otherwise