Created
August 6, 2020 19:08
-
-
Save Raks-coder/fc0ddcf5574ba9c8c969e60584a3e1dc 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.5.1; | |
contract MyContract | |
{ | |
mapping(address=>uint256)public balances; | |
event Purchase( | |
address indexed _buyer, | |
uint256 _amount); | |
address payable wallet; | |
constructor (address payable _wallet) public | |
{ | |
wallet=_wallet; | |
} | |
function() external payable | |
{ | |
buyToken(); | |
} | |
function buyToken() public payable | |
{ | |
//buy a token | |
balances[msg.sender]+=1; | |
//send ether to wallet | |
wallet.transfer(msg.value); | |
emit Purchase(msg.sender,1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment