Last active
February 18, 2019 19:11
-
-
Save prestwich/2da5cc36ff2fee5100343ba514598dc1 to your computer and use it in GitHub Desktop.
Nonfungibilizer.sol
This file contains hidden or 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
// This is an alpha contract designed to be proxied | |
// It is NOT production ready | |
contract Nonfungiblizer { | |
bool initDone; | |
address owner; | |
address asset; | |
uint256 value; | |
constructor () {} | |
function init(address _asset, uint256 _value) { | |
require(!initDone); | |
require(_value > 0, '_value must be greater than 0'); | |
require( | |
IERC20(_asset).transferFrom(msg.sender, address(this), _value), | |
'transferFrom failed' | |
); | |
asset = _asset; | |
value = _value; | |
initDone = true; | |
} | |
function withdraw(address _recipient) { | |
require(msg.sender == owner); | |
IERC20(_asset).transfer(_recipient, value); | |
selfdestruct(); | |
} | |
function transfer(address _newOwner) { | |
require(msg.sender == owner); | |
owner = _newOwner; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment