Created
May 6, 2022 10:15
-
-
Save ilamanov/a95434b08430a5137daef3f2c3878c4f 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
contract BuyOptionForUNIToken { | |
address public constant UNIERC20Address = "0x...."; | |
uint public price; | |
uint public endPeriod; | |
address public contractHolder; | |
constructor(uint _price, uint _endPeriod, address _contractHolder) { | |
price = _price; | |
endPeriod = _endPeriod; | |
contractHolder = _contractHolder; | |
} | |
function buy(uint amount) { | |
require(msg.sender == contractHolder, "You are not the contract holder"); | |
require(msg.value >= (amount * price), "Not enough ETH"); | |
require(block.timestamp < endPeriod, "Contract expired"); | |
ERC20(UNIERC20Address).transfer(msg.sender, amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment