Skip to content

Commit

Permalink
learning/practice solidity
Browse files Browse the repository at this point in the history
  • Loading branch information
MahithChigurupati committed Dec 16, 2022
1 parent f412198 commit e8b3e9f
Show file tree
Hide file tree
Showing 6 changed files with 764 additions and 0 deletions.
42 changes: 42 additions & 0 deletions burn.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract token is ERC20("MahithTest","MCT"){

address public creator;
mapping(address => uint) public points;

constructor() payable{
creator = msg.sender;
}

modifier onlyOwner(){
require(msg.sender == creator, "Only owner is allowed");
_;
}

function mintNewToken(uint amount) public onlyOwner{
_mint(msg.sender, amount);
}

function burnAndAdd(uint amount) public {
_burn(msg.sender,amount);
points[msg.sender] += amount;
}

function burned(address check) public view returns(uint){
return points[check];
}

function win() public {
if(points[msg.sender] > 5){
selfdestruct(payable(msg.sender));
}else{
revert("you don't have enough tokens to win");
}
}

}
Loading

0 comments on commit e8b3e9f

Please sign in to comment.