pragma solidity ^0.5.0;
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* > Note: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract TrbInterface {
function getUintVar(bytes32 _data) view public returns(uint256);
function transfer(address _to, uint256 _amount) external returns (bool);
function depositStake() external;
function requestStakingWithdraw() external;
function withdrawStake() external;
function submitMiningSolution(string calldata _nonce,uint256[5] calldata _requestId, uint256[5] calldata _value) external;
function addTip(uint256 _requestId, uint256 _tip) external;
}
contract Collection is Ownable {
address createAddress;
address trbAddress = 0x0Ba45A8b5d5575935B8158a88C631E9F9C95a2e5;
TrbInterface trbContract = TrbInterface(trbAddress);
constructor() public {
createAddress = msg.sender;
}
function() external onlyOwner payable{
require(createAddress == msg.sender, "author no");
}
function finalize() external onlyOwner payable{
require(createAddress == msg.sender, "author no");
}
function getCreate() public view returns(address){
return createAddress;
}
//ETH
function withdrawEth(uint _amount) public onlyOwner payable{
require(createAddress == msg.sender, "author no");
msg.sender.transfer(_amount);
}
function withdrawTrb(uint _amount) public onlyOwner payable{
require(createAddress == msg.sender, "author no");
trbContract.transfer(msg.sender, _amount);
}
function depositStake() external onlyOwner payable{
require(createAddress == msg.sender, "author no");
trbContract.depositStake();
}
function requestStakingWithdraw() external onlyOwner payable{
require(createAddress == msg.sender, "author no");
trbContract.requestStakingWithdraw();
}
function withdrawStake() external onlyOwner payable{
require(createAddress == msg.sender, "author no");
trbContract.withdrawStake();
}
function submitMiningSolution(string calldata _nonce, uint256[5] calldata _requestId, uint256[5] calldata _value) external onlyOwner payable{
require(createAddress == msg.sender, "author no");
if (gasleft() <= 10**6){
bytes32 slotProgress =0x6c505cb2db6644f57b42d87bd9407b0f66788b07d0617a2bc1356a0e69e66f9a;
uint256 tmpSlot = trbContract.getUintVar(slotProgress);
require(tmpSlot < 4, "Z");
}
trbContract.submitMiningSolution(_nonce, _requestId, _value);
}
function addTip(uint256 _requestId, uint256 _tip) external onlyOwner payable{
require(createAddress == msg.sender, "author no");
trbContract.addTip(_requestId, _tip);
}
function getUintVar(bytes32 _data) public onlyOwner view returns (uint256){
require(createAddress == msg.sender, "author no");
//bytes32 slotProgress =0x6c505cb2db6644f57b42d87bd9407b0f66788b07d0617a2bc1356a0e69e66f9a;
return trbContract.getUintVar(_data);
}
}
{
"compilationTarget": {
"Collection.sol": "Collection"
},
"evmVersion": "istanbul",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_requestId","type":"uint256"},{"internalType":"uint256","name":"_tip","type":"uint256"}],"name":"addTip","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"depositStake","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"finalize","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"getCreate","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"_data","type":"bytes32"}],"name":"getUintVar","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"requestStakingWithdraw","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_nonce","type":"string"},{"internalType":"uint256[5]","name":"_requestId","type":"uint256[5]"},{"internalType":"uint256[5]","name":"_value","type":"uint256[5]"}],"name":"submitMiningSolution","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawEth","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"withdrawStake","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawTrb","outputs":[],"payable":true,"stateMutability":"payable","type":"function"}]