SafeERC20.sol [Code Snippet]
Ensures safe token operations by reverting on failure.

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import "../ERC20.sol";


library SafeERC20 {

  function safeTransfer(ERC20 token, address to, uint256 value) internal {

    require(token.transfer(to, value), "SafeERC20: transfer failed");

  }

   

  function safeTransferFrom(ERC20 token, address from, address to, uint256 value) internal {

    require(token.transferFrom(from, to, value), "SafeERC20: transferFrom failed");

  }

   

  // Additional safe operations can be added here.

}

Share by: