Skip to content

Instantly share code, notes, and snippets.

@jhaym3s
Last active April 23, 2023 12:20
Show Gist options
  • Save jhaym3s/576a0a071534c3e647dbf3cc99e58a86 to your computer and use it in GitHub Desktop.
Save jhaym3s/576a0a071534c3e647dbf3cc99e58a86 to your computer and use it in GitHub Desktop.
pragma solidity ^0.8.0;
contract Token {
string public name = "Manuel";
string public symbol = "MKPA";
uint256 public totalSupply = 1000000;
uint256 public decimals = 18;
mapping(address => uint256) balances;
constructor() {
balances[msg.sender] = totalSupply;
}
function buyTokens(uint256 amount) public {
require(amount > 0, "Amount should be greater than 0");
require(balances[msg.sender] + amount <= totalSupply * 30 / 100, "more than maximum 30% of total supply");
balances[msg.sender] += amount;
totalSupply -= amount;
}
function balanceOf(address account) public view returns (uint256) {
return balances[account];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment