Skip to content

Instantly share code, notes, and snippets.

@feliam
Created December 13, 2019 01:31
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 feliam/712a3089af6fb784b299553b6dd60bef to your computer and use it in GitHub Desktop.
Save feliam/712a3089af6fb784b299553b6dd60bef to your computer and use it in GitHub Desktop.
contract PepeCoin{
uint dec = 10**18;
mapping(address => uint) balances;
function buy(uint tokens) public payable{
uint required_wei = (tokens / 10) * dec;
if (msg.value >= required_wei){
balances[msg.sender] += tokens;
}else{
revert();
}
}
function sell(uint tokens) public payable{
uint wei_to_send = ( tokens / 10 ) * dec;
if (balances[msg.sender] >= tokens){
msg.sender.transfer(wei_to_send);
balances[msg.sender] -= wei_to_send*10;
}
}
function transfer(address to, uint tokens) public {
require(balances[msg.sender] >= tokens);
balances[msg.sender] -= tokens;
balances[to] += tokens;
}
}
@feliam
Copy link
Author

feliam commented Dec 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment