Last active
May 12, 2021 10:11
-
-
Save JackieXu/3ec442a4017c8198a1d4cb262e0f1c69 to your computer and use it in GitHub Desktop.
Get ready for Scamp the Tramp
This file contains 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
// SPDX-License-Identifier: Unlicensed | |
pragma solidity ^0.8.4; | |
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | |
contract Scamp is ERC20 { | |
using SafeERC20 for IERC20; | |
IERC20 public constant inv = IERC20(address(0x41D5D79431A913C4aE7d69a668ecdfE5fF9DFB68)); | |
constructor() ERC20("Scamp", "SCAMP") {} | |
function decimals() public pure override returns (uint8) { | |
return 8; | |
} | |
function happyTailwag(uint256 happiness) external returns (bool) { | |
uint256 inv_balance = inv.balanceOf(msg.sender); | |
uint256 mint_amount = happiness < inv_balance ? happiness : inv_balance; | |
inv.safeTransferFrom(msg.sender, address(this), mint_amount); | |
_mint(msg.sender, mint_amount); | |
return true; | |
} | |
function sadTailwag(uint256 sadness) external returns (bool) { | |
uint256 burn_amount = sadness < balanceOf(msg.sender) ? sadness : balanceOf(msg.sender); | |
_burn(msg.sender, burn_amount); | |
inv.safeTransfer(msg.sender, burn_amount); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment