Skip to content

Instantly share code, notes, and snippets.

@vieyang
Created June 10, 2020 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vieyang/258ff4edf6a30d58e4e94c0749f5ff8e to your computer and use it in GitHub Desktop.
Save vieyang/258ff4edf6a30d58e4e94c0749f5ff8e to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.24;
/**
* Utility library of inline functions on addresses
*/
library Address {
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*/
function sendValue(address recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
bool success = recipient.call.value(amount)("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment