Created
March 22, 2023 00:41
-
-
Save madhavanmalolan/eaad6ac82c5a9840122409638bf52d94 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
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.9; | |
// Uncomment this line to use console.log | |
import "hardhat/console.sol"; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
contract Troubleshoot is ERC20, Ownable { | |
mapping(address => uint256) public totalEarnings; | |
constructor() ERC20("Troubleshoot Token Yeild", "TTY") { | |
} | |
event Mint(address indexed to, uint256 amount); | |
uint contractSubmissionFeeMintingFactor = 1_002_000; | |
function setContractSubmissionFeeMintingFactor(uint _contractSubmissionFeeMintingFactor) public onlyOwner { | |
contractSubmissionFeeMintingFactor = _contractSubmissionFeeMintingFactor; | |
} | |
function mint(address to, uint256 amount) public onlyOwner { | |
_mint(to, amount); | |
totalEarnings[to] += amount; | |
emit Mint(to, amount); | |
contractSubmissionFeeMintingFactor *= contractSubmissionFeeMintingFactor / 1_000_000; | |
} | |
function earnings(address account) public view returns (uint256) { | |
return totalEarnings[account]; | |
} | |
function transferOwnership(address newOwner) public override onlyOwner { | |
super.transferOwnership(newOwner); | |
} | |
uint bugRatioNumerator = 1; | |
uint bugRatioDenominator = 10; | |
function setBugRatio(uint numerator, uint denominator) public onlyOwner { | |
bugRatioNumerator = numerator; | |
bugRatioDenominator = denominator; | |
} | |
function getBugRatio() public view returns (uint, uint) { | |
return (bugRatioNumerator, bugRatioDenominator); | |
} | |
uint rewardPerCorrectSubmission = 10 ether; | |
function setRewardPerCorrectSubmission(uint _rewardPerCorrectSubmission) public onlyOwner { | |
rewardPerCorrectSubmission = _rewardPerCorrectSubmission; | |
} | |
function getRewardPerCorrectSubmission() public view returns (uint) { | |
return rewardPerCorrectSubmission; | |
} | |
uint contractSubmissionFee = 0.01 ether; | |
uint contractSubmissionFeeContractFactor = 1_070_000; | |
uint lastSubmissionTime = 0; | |
function setContractSubmissionFee(uint _contractSubmissionFee) public onlyOwner { | |
contractSubmissionFee = _contractSubmissionFee; | |
} | |
function getContractSubmissionFee() public view returns (uint) { | |
uint expectedFees = contractSubmissionFee * contractSubmissionFeeMintingFactor / (contractSubmissionFeeContractFactor/1_000_000) ** ((block.timestamp - lastSubmissionTime)/24/60/60); | |
return expectedFees; | |
} | |
bool reentry = false; | |
event ContractSubmitted(address account, bytes32 contractHash); | |
function submitContract(bytes32 contractHash) public { | |
if (reentry) { | |
return; | |
} | |
reentry = true; | |
_transfer(msg.sender, address(this), getContractSubmissionFee()); | |
reentry = false; | |
emit ContractSubmitted(msg.sender, contractHash); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment