Skip to content

Instantly share code, notes, and snippets.

@Raks-coder
Created August 6, 2020 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raks-coder/fc0ddcf5574ba9c8c969e60584a3e1dc to your computer and use it in GitHub Desktop.
Save Raks-coder/fc0ddcf5574ba9c8c969e60584a3e1dc to your computer and use it in GitHub Desktop.
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