SafeERC20
Wrappers around ERC20 operations that throw on failure (when the token
contract returns false). Tokens that return no value (and instead revert or
throw on failure) are also supported, non-reverting calls are assumed to be
successful.
To use this library you can add a using SafeERC20 for IERC20;
statement to your contract,
which allows you to call the safe operations as token.safeTransfer(...)
, etc.
Functions
increaseAllowance
Increases the allowance granted to spender
by the caller.
function increaseAllowance(IERC20 _token, address _spender, uint256 _addedValue) internal returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | Token to transfer. |
_spender | address | The address which will spend the funds. |
_addedValue | uint256 | The amount of tokens to increase the allowance by. |
safeTransfer
Calls transfer() without reverting.
function safeTransfer(IERC20 _token, address _to, uint256 _value) internal returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | Token to transfer. |
_to | address | Recepient address. |
_value | uint256 | Amount transferred. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether transfer succeeded or not. |
safeTransferFrom
Calls transferFrom() without reverting.
function safeTransferFrom(IERC20 _token, address _from, address _to, uint256 _value) internal returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_token | IERC20 | Token to transfer. |
_from | address | Sender address. |
_to | address | Recepient address. |
_value | uint256 | Amount transferred. |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | Whether transfer succeeded or not. |