Skip to content

Instantly share code, notes, and snippets.

@tienshaoku
Last active March 24, 2020 14:56
Show Gist options
  • Save tienshaoku/5b3accdf5af1f876327cc9694d42b511 to your computer and use it in GitHub Desktop.
Save tienshaoku/5b3accdf5af1f876327cc9694d42b511 to your computer and use it in GitHub Desktop.
The filename ends with .py for Python syntax highlighting
import ERC20 as ERC20
owner: public(address)
tokenAddress: public(address)
erc20: ERC20
@public
def __init__(_tokenAddress: address):
self.owner = msg.sender
self.tokenAddress = _tokenAddress
self.erc20 = ERC20(self.tokenAddress)
@payable
@public
def buyToken():
assert msg.value == 10 ** 16
assert_modifiable(self.erc20.transfer(msg.sender, 500))
@public
def endSale():
assert msg.sender == self.owner
selfdestruct(self.owner)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment