Created
June 10, 2020 14:34
-
-
Save vieyang/258ff4edf6a30d58e4e94c0749f5ff8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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