Created
February 2, 2023 11:29
-
-
Save bartubozkurt/a3b06dd20ae9e06d86b33594f62d498f 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.22; | |
/* Bad */ | |
contract BadERC20Token{ | |
function transfer(address to, uint value) external; | |
//... | |
} | |
/* Better */ | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/SafeERC20.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol"; | |
contract GoodERC20Token { | |
using SafeERC20 for IERC20; | |
IERC20 public _token; | |
function transfer(address to, uint value) external { | |
_token.transfer(to,value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment