编译器
0.5.16+commit.9c3226ce
文件 1 的 4:ERC20Interface.sol
pragma solidity ^0.5.10;
contract ERC20Interface {
function totalSupply()
public
view
returns (uint256);
function balanceOf(address tokenOwner)
public
view
returns (uint256 balance);
function allowance
(address tokenOwner, address spender)
public
view
returns (uint256 remaining);
function transfer(address to, uint256 tokens) public
returns (bool success);
function approve(address spender, uint256 tokens) public
returns (bool success);
function transferFrom
(address from, address to, uint256 tokens) public
returns (bool success);
event Transfer(address indexed from, address indexed to, uint256 tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint256 tokens);
}
文件 2 的 4:Ownable.sol
pragma solidity ^0.5.10;
contract Ownable {
address payable public owner;
address payable internal _newOwner;
constructor() public {
owner = msg.sender;
}
event OwnershipTransferred(address previousOwner, address newOwner);
function setOwner(address payable newOwner) internal {
_newOwner = newOwner;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not Owner");
_;
}
function transferOwnership(address payable newOwner) public onlyOwner {
require(newOwner != address(0), "Invalid Address");
setOwner(newOwner);
}
function acceptOwnership() public returns (address){
require(msg.sender == _newOwner,"Invalid new owner");
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
_newOwner = address(0);
return owner;
}
}
文件 3 的 4:ReinvestMoondayFinance.sol
pragma solidity ^0.5.10;
import "./SafeMath.sol";
import "./ERC20Interface.sol";
import "./Ownable.sol";
contract ReinvestMoondayFinance is Ownable {
using SafeMath for uint256;
ERC20Interface MoondayToken;
address payable public moondayFinanceContract;
event Reinvested(uint256 amount);
constructor(address _MoondayToken) public {
owner = msg.sender;
MoondayToken = ERC20Interface(_MoondayToken);
}
function setMoondayContractAddress(address payable _moondayFinanceContract) public onlyOwner{
moondayFinanceContract = _moondayFinanceContract;
}
function reinvest() public {
require(moondayFinanceContract != address(0), "Invalid Moonday Capital Contract Address");
require(MoondayToken.balanceOf(address(this)) > 0, "Invalid Token Balance to reinvest");
uint256 amount = MoondayToken.balanceOf(address(this));
MoondayToken.transfer(moondayFinanceContract, amount);
emit Reinvested(amount);
}
}
文件 4 的 4:SafeMath.sol
pragma solidity ^0.5.10;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
return c;
}
}
{
"compilationTarget": {
"ReinvestMoondayFinance.sol": "ReinvestMoondayFinance"
},
"evmVersion": "istanbul",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_MoondayToken","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Reinvested","type":"event"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"moondayFinanceContract","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"reinvest","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"_moondayFinanceContract","type":"address"}],"name":"setMoondayContractAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]