Skip to content

Instantly share code, notes, and snippets.

@madhavanmalolan
Created March 22, 2023 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madhavanmalolan/eaad6ac82c5a9840122409638bf52d94 to your computer and use it in GitHub Desktop.
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=
// 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