Last active
April 23, 2023 12:20
-
-
Save jhaym3s/576a0a071534c3e647dbf3cc99e58a86 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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