ETH Price: $2,473.07 (+7.31%)

Contract

0x0D19d264207a3aFad4094F26b693ff5590361B0d
 

Overview

ETH Balance

0.100000000000000013 ETH

Eth Value

$247.31 (@ $2,473.07/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Release Roto86789322019-10-05 0:32:411811 days ago1570235561IN
0x0D19d264...590361B0d
0 ETH0.0005944610
Stake86789222019-10-05 0:30:581811 days ago1570235458IN
0x0D19d264...590361B0d
0 ETH0.000102161
Create Tournamen...86789172019-10-05 0:29:171811 days ago1570235357IN
0x0D19d264...590361B0d
0 ETH0.002212215
Release Roto86789102019-10-05 0:27:561811 days ago1570235276IN
0x0D19d264...590361B0d
0 ETH0.000741910
Stake86788992019-10-05 0:25:291811 days ago1570235129IN
0x0D19d264...590361B0d
0 ETH0.000102221
Create Tournamen...86788502019-10-05 0:16:341811 days ago1570234594IN
0x0D19d264...590361B0d
0 ETH0.0022131615
Reward Roto86710952019-10-03 19:20:081812 days ago1570130408IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86710372019-10-03 19:05:531812 days ago1570129553IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86709602019-10-03 18:51:001812 days ago1570128660IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86708942019-10-03 18:36:341812 days ago1570127794IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86708192019-10-03 18:22:241812 days ago1570126944IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86708162019-10-03 18:21:501812 days ago1570126910IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86707412019-10-03 18:07:251812 days ago1570126045IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86706772019-10-03 17:52:281812 days ago1570125148IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86706252019-10-03 17:37:411812 days ago1570124261IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86705562019-10-03 17:22:421812 days ago1570123362IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86704992019-10-03 17:08:441812 days ago1570122524IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86704282019-10-03 16:53:551812 days ago1570121635IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86702812019-10-03 16:20:271813 days ago1570119627IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86702002019-10-03 16:04:361813 days ago1570118676IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86701232019-10-03 15:48:241813 days ago1570117704IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86700712019-10-03 15:37:131813 days ago1570117033IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86699972019-10-03 15:22:021813 days ago1570116122IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86699172019-10-03 15:05:361813 days ago1570115136IN
0x0D19d264...590361B0d
0 ETH0.0004116415
Reward Roto86698572019-10-03 14:50:211813 days ago1570114221IN
0x0D19d264...590361B0d
0 ETH0.0004116415
View all transactions

Latest 18 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
86789322019-10-05 0:32:411811 days ago1570235561
0x0D19d264...590361B0d
3 ETH
86789102019-10-05 0:27:561811 days ago1570235276
0x0D19d264...590361B0d
3 wei
69541002018-12-26 4:00:232094 days ago1545796823
0x0D19d264...590361B0d
0.62128444 ETH
69540972018-12-26 3:59:292094 days ago1545796769
0x0D19d264...590361B0d
0.37871555 ETH
68676362018-12-11 15:35:172109 days ago1544542517
0x0D19d264...590361B0d
0.33891184 ETH
68676342018-12-11 15:33:552109 days ago1544542435
0x0D19d264...590361B0d
0.66108815 ETH
68270912018-12-04 22:25:142115 days ago1543962314
0x0D19d264...590361B0d
0.43470451 ETH
68270642018-12-04 22:16:592115 days ago1543961819
0x0D19d264...590361B0d
0.56529548 ETH
67802522018-11-27 4:38:532123 days ago1543293533
0x0D19d264...590361B0d
1.25 ETH
67402482018-11-20 15:24:072130 days ago1542727447
0x0D19d264...590361B0d
0.5 ETH
67402222018-11-20 15:16:342130 days ago1542726994
0x0D19d264...590361B0d
0.1 ETH
67402082018-11-20 15:10:412130 days ago1542726641
0x0D19d264...590361B0d
0.4 ETH
66953722018-11-13 6:38:252137 days ago1542091105
0x0D19d264...590361B0d
0.911136 ETH
66953702018-11-13 6:37:512137 days ago1542091071
0x0D19d264...590361B0d
0.08886399 ETH
66522002018-11-06 5:10:092144 days ago1541481009
0x0D19d264...590361B0d
0.50624967 ETH
66521982018-11-06 5:08:552144 days ago1541480935
0x0D19d264...590361B0d
0.49375032 ETH
65695862018-10-23 16:24:082158 days ago1540311848
0x0D19d264...590361B0d
1 ETH
65269582018-10-16 17:12:422164 days ago1539709962
0x0D19d264...590361B0d
0.9 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RotoManager

Compiler Version
v0.4.24+commit.e67f0147

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2018-09-01
*/

pragma solidity 0.4.24;

/**
 * @title SafeMath
 * @dev Math operations with safety checks that throw on error
 */
library SafeMath {

  /**
  * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
  */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        assert(b <= a);
        return a - b;
    }

  /**
  * @dev Adds two numbers, throws on overflow.
  */
    function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
        c = a + b;
        assert(c >= a);
        return c;
    }
}


/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
contract ERC20 {
    function allowance(address owner, address spender) public view returns (uint256);
    function transferFrom(address from, address to, uint256 value) public returns (bool);
    function approve(address spender, uint256 value) public returns (bool);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    function totalSupply() public view returns (uint256);
    function balanceOf(address who) public view returns (uint256);
    function transfer(address to, uint256 value) public returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
}

/**
 * @title Standard ERC20 token
 *
 * @dev Implementation of the basic standard token.
 * @dev https://github.com/ethereum/EIPs/issues/20
 * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 */
contract StandardToken is ERC20 {

    using SafeMath for uint256;

    mapping(address => uint256) balances;

    uint256 totalSupply_;
    mapping (address => mapping (address => uint256)) internal allowed;


  /**
   * @dev Transfer tokens from one address to another
   * @param _from address The address which you want to send tokens from
   * @param _to address The address which you want to transfer to
   * @param _value uint256 the amount of tokens to be transferred
   */
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
        require(_to != address(0));
        require(_value <= balances[_from]);
        require(_value <= allowed[_from][msg.sender]);

        balances[_from] = balances[_from].sub(_value);
        balances[_to] = balances[_to].add(_value);
        allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
        emit Transfer(_from, _to, _value);
        return true;
    }

  /**
   * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
   *
   * Beware that changing an allowance with this method brings the risk that someone may use both the old
   * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
   * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
   * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
   * @param _spender The address which will spend the funds.
   * @param _value The amount of tokens to be spent.
   */
    function approve(address _spender, uint256 _value) public returns (bool) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }

  /**
   * @dev Function to check the amount of tokens that an owner allowed to a spender.
   * @param _owner address The address which owns the funds.
   * @param _spender address The address which will spend the funds.
   * @return A uint256 specifying the amount of tokens still available for the spender.
   */
    function allowance(address _owner, address _spender) public view returns (uint256) {
        return allowed[_owner][_spender];
    }

  /**
   * @dev Increase the amount of tokens that an owner allowed to a spender.
   *
   * approve should be called when allowed[_spender] == 0. To increment
   * allowed value is better to use this function to avoid 2 calls (and wait until
   * the first transaction is mined)
   * From MonolithDAO Token.sol
   * @param _spender The address which will spend the funds.
   * @param _addedValue The amount of tokens to increase the allowance by.
   */
    function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
        allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }

  /**
   * @dev Decrease the amount of tokens that an owner allowed to a spender.
   *
   * approve should be called when allowed[_spender] == 0. To decrement
   * allowed value is better to use this function to avoid 2 calls (and wait until
   * the first transaction is mined)
   * From MonolithDAO Token.sol
   * @param _spender The address which will spend the funds.
   * @param _subtractedValue The amount of tokens to decrease the allowance by.
   */
    function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
        uint oldValue = allowed[msg.sender][_spender];
        if (_subtractedValue > oldValue) {
            allowed[msg.sender][_spender] = 0;
        } else {
            allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
        }
        emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }

     /**
  * @dev total number of tokens in existence
  */
    function totalSupply() public view returns (uint256) {
        return totalSupply_;
    }

  /**
  * @dev transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  */
    function transfer(address _to, uint256 _value) public returns (bool) {
        require(_to != address(0));
        require(_value <= balances[msg.sender]);

        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);
        return true;
    }

  /**
  * @dev Gets the balance of the specified address.
  * @param _owner The address to query the the balance of.
  * @return An uint256 representing the amount owned by the passed address.
  */
    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];
    }

}

contract RotoToken is StandardToken {

    string public constant name = "Roto"; // token name
    string public constant symbol = "ROTO"; // token symbol
    uint8 public constant decimals = 18; // token decimal

    uint256 public constant INITIAL_SUPPLY = 21000000 * (10 ** uint256(decimals));
    address owner;
    address roto = this;
    address manager;

    // keeps track of the ROTO currently staked in a tournament
    // the format is user address -> the tournament they staked in -> how much they staked
    mapping (address => mapping (bytes32 => uint256)) stakes;
    uint256 owner_transfer = 2000000 * (10** uint256(decimals));
  /**
   * @dev Constructor that gives msg.sender all of existing tokens.
   */

    modifier onlyOwner {
        require(msg.sender==owner);
        _;
    }

    modifier onlyManager {
      require(msg.sender==manager);
      _;
    }

    event ManagerChanged(address _contract);
    event RotoStaked(address _user, uint256 stake);
    event RotoReleased(address _user, uint256 stake);
    event RotoDestroyed(address _user, uint256 stake);
    event RotoRewarded(address _contract, address _user, uint256 reward);

    constructor() public {
        owner = msg.sender;
        totalSupply_ = INITIAL_SUPPLY;
        balances[roto] = INITIAL_SUPPLY;
        emit Transfer(0x0, roto, INITIAL_SUPPLY);
    }

    
    /**
     *  @dev A function that can only be called by RotoHive, transfers Roto Tokens out of the contract.
        @param _to address, the address that the ROTO will be transferred to
        @param _value ROTO, amount to transfer
        @return - whether the Roto was transferred succesfully
     */
    function transferFromContract(address _to, uint256 _value) public onlyOwner returns(bool) {
        require(_to!=address(0));
        require(_value<=balances[roto]);
        require(owner_transfer > 0);

        owner_transfer = owner_transfer.sub(_value);
        
        balances[roto] = balances[roto].sub(_value);
        balances[_to] = balances[_to].add(_value);

        emit Transfer(roto, _to, _value);
        return true;
    }

    /**
        @dev updates the helper contract(which will manage the tournament) with the new version
        @param _contract address, the address of the manager contract
        @return - whether the contract was successfully set
    */
    function setManagerContract(address _contract) external onlyOwner returns(bool) {
      //checks that the address sent isn't the 0 address, the owner or the token contract
      require(_contract!=address(0)&&_contract!=roto);

      // requires that the address sent be a contract
      uint size;
      assembly { size := extcodesize(_contract) }
      require(size > 0);

      manager = _contract;

      emit ManagerChanged(_contract);
      return true;
    }

    /**
        @dev - called by the manager contract to add back to the user their roto in the event that their submission was successful
        @param  _user address, the address of the user who submitted the rankings
        @param _tournamentID identifier
        @return boolean value, whether the roto were successfully released
    */
    function releaseRoto(address _user, bytes32 _tournamentID) external onlyManager returns(bool) {
        require(_user!=address(0));
        uint256 value = stakes[_user][_tournamentID];
        require(value > 0);

        stakes[_user][_tournamentID] = 0;
        balances[_user] = balances[_user].add(value);

        emit RotoReleased(_user, value);
        return true;
    }

    /**
        @dev - function called by manager contract to process the accounting aspects of the destroyRoto function
        @param  _user address, the address of the user who's stake will be destroyed
        @param _tournamentID identifier
        @return - a boolean value that reflects whether the roto were successfully destroyed
    */
    function destroyRoto(address _user, bytes32 _tournamentID) external onlyManager returns(bool) {
        require(_user!=address(0));
        uint256 value = stakes[_user][_tournamentID];
        require(value > 0);

        stakes[_user][_tournamentID] = 0;
        balances[roto] = balances[roto].add(value);

        emit RotoDestroyed(_user, value);
        return true;
    }

    /**
        @dev - called by the manager contract, runs the accounting portions of the staking process
        @param  _user address, the address of the user staking ROTO
        @param _tournamentID identifier
        @param _value ROTO, the amount the user is staking
        @return - whether the staking process went successfully
    */
    function stakeRoto(address _user, bytes32 _tournamentID, uint256 _value) external onlyManager returns(bool) {
        require(_user!=address(0));
        require(_value<=balances[_user]);
        require(stakes[_user][_tournamentID] == 0);

        balances[_user] = balances[_user].sub(_value);
        stakes[_user][_tournamentID] = _value;

        emit RotoStaked(_user, _value);
        return true;
    }
    
    /**
      @dev - called by the manager contract, used to reward non-staked submissions by users
      @param _user address, the address that will receive the rewarded ROTO
      @param _value ROTO, the amount of ROTO that they'll be rewarded
     */
    function rewardRoto(address _user, uint256 _value) external onlyManager returns(bool successful) {
      require(_user!=address(0));
      require(_value<=balances[roto]);

      balances[_user] = balances[_user].add(_value);
      balances[roto] = balances[roto].sub(_value);

      emit Transfer(roto, _user, _value);
      return true;
    }
    /**
        @dev - to be called by the manager contract to check if a given user has enough roto to
            stake the given amount
        @param  _user address, the address of the user who's attempting to stake ROTO
        @param _value ROTO, the amount they are attempting to stake
        @return - whether the user has enough balance to stake the received amount
    */
    function canStake(address _user, uint256 _value) public view onlyManager returns(bool) {
      require(_user!=address(0));
      require(_value<=balances[_user]);

      return true;
    }

    /**
      @dev Getter function for manager
     */
    function getManager() public view returns (address _manager) {
      return manager;
    }

    /**
      @dev - sets the owner address to a new one
      @param  _newOwner address
      @return - true if the address was changed successful
     */
    function changeOwner(address _newOwner) public onlyOwner returns(bool) {
      owner = _newOwner;
    }
}

contract RotoBasic {

    mapping (bytes32 => Tournament) public tournaments;  // tournamentID
    
    //Instance and Address of the RotoToken contract
    RotoToken token;
    address roto;

    //Address of the contract owner the manager contract(this contract)
    address owner;
    address manager;

    //boolean variable that determines whether there's an emergency state
    bool emergency;

    struct Tournament {
        bool open;
        // the total ether prize and how much is left
        uint256 etherPrize;
        uint256 etherLeft;
        // the total roto prize how much is left
        uint256 rotoPrize;
        uint256 rotoLeft;
        // tournament details
        uint256 creationTime;
        mapping (address => mapping (bytes32 => Stake)) stakes;  // address of staker, to tournament ID points to a specific stake
        //counters to easily tell the # of stakes vs # of stakes resolved
        uint256 userStakes;
        uint256 stakesResolved;
    }

    struct Stake {
        uint256 amount; // Once the stake is resolved, this becomes 0
        bool successful;
        bool resolved;
    }

    modifier onlyOwner {
      require(msg.sender==owner);
      _;
    }

    modifier stopInEmergency {
      require(emergency==false);
      _;
    }

    //Tournament Creation and Processing Events
    event StakeProcessed(address indexed staker, uint256 totalAmountStaked, bytes32 indexed tournamentID);
    event StakeDestroyed(bytes32 indexed tournamentID, address indexed stakerAddress, uint256 rotoLost);
    event StakeReleased(bytes32 indexed tournamentID, address indexed stakerAddress, uint256 etherReward, uint256 rotoStaked);
    event SubmissionRewarded(bytes32 indexed tournamentID, address indexed stakerAddress, uint256 rotoReward);
    
    event TokenChanged(address _contract);
    event TournamentCreated(bytes32 indexed tournamentID, uint256 etherPrize, uint256 rotoPrize);
    event TournamentClosed(bytes32 indexed tournamentID);

    /**
       @dev - sets the token contract to used for the token accounting
       @param _contract address, the address of the token contract
       @return - true if the token contract was set successfully
    */
    function setTokenContract(address _contract) public onlyOwner returns(bool) {
      require(_contract!=address(0)&&_contract!=manager);

      // requires that the address sent be a contract
      uint size;
      assembly { size := extcodesize(_contract) }
      require(size > 0);

      roto = _contract;
      token = RotoToken(roto);

      emit TokenChanged(_contract);
      return true;
    }

    /**
        @dev - sets the state of the emegency variable to true, preventing any of the tournament processes to run
        @param _emergency boolean variable to set emergency to
        @return - true if the variable was changed successfully
    */
    function setEmergency(bool _emergency) public onlyOwner returns(bool) {
      emergency = _emergency;
      return true;
    }

    /**
      @dev - sets the owner address to a new one
      @param  _newOwner address
      @return - true if the address was changed successful
     */
    function changeOwner(address _newOwner) public onlyOwner returns(bool) {
      owner = _newOwner;
    }

}

contract RotoManager is RotoBasic {

    using SafeMath for uint256;

    constructor() public {
      owner = msg.sender;
      emergency = false;
      manager = this;
    }

    /**
        @dev - In the event that their submissions were successful, this function will return the tokens to the user, and distribute ether rewards were applicable
        @param _user The user's address, the ether the've won,
        @return - returns whether the Roto was sucessfully transferred
     */
    function releaseRoto(address _user, bytes32 _tournamentID, uint256 _etherReward) external onlyOwner stopInEmergency returns(bool successful){
        Tournament storage tournament = tournaments[_tournamentID];
        require(tournament.open==true);

        Stake storage user_stake = tournament.stakes[_user][_tournamentID];
        uint256 initial_stake = user_stake.amount;

        // prelimiary checks 
        require(initial_stake > 0);
        require(user_stake.resolved == false);

        // ether balance rewards
        require(manager.balance > _etherReward);
        require(tournament.etherLeft >= _etherReward);

        //Redistributes roto back to the user, and marks the stake as successful and completed
        user_stake.amount = 0;
        assert(token.releaseRoto(_user, _tournamentID)); // calls the token contract releaseRoto function to handle the token accounting
        tournament.stakesResolved = tournament.stakesResolved.add(1);
        
        user_stake.resolved = true;
        user_stake.successful = true;

        if(_etherReward > 0) {
          tournament.etherLeft = tournament.etherLeft.sub(_etherReward);
          _user.transfer(_etherReward);
        }

        emit StakeReleased(_tournamentID, _user, _etherReward, initial_stake);
        
        return true;
    }
    /**
        @dev - If the user did not stake ROTO, but they still had a successful submission, then RotoHive will reward the user with an amount of ROTO respective to their performance.
        @param _user address, which the ROTO will be sent to
        @param _rotoReward amount of ROTO that the user has won
        @return - a boolean value determining whether the operation was successful
    
     */
    function rewardRoto(address _user, bytes32 _tournamentID, uint256 _rotoReward) external onlyOwner stopInEmergency returns(bool successful) {
      Tournament storage tournament = tournaments[_tournamentID];
      require(tournament.open==true);

      Stake storage user_stake = tournament.stakes[_user][_tournamentID];
      uint256 initial_stake = user_stake.amount;
      
      require(initial_stake==0);
      require(tournament.rotoLeft >= _rotoReward);
      require(user_stake.resolved == false);

      tournament.rotoLeft = tournament.rotoLeft.sub(_rotoReward);
      assert(token.rewardRoto(_user, _rotoReward));

      user_stake.resolved = true;
      user_stake.successful = true;

      emit SubmissionRewarded(_tournamentID, _user, _rotoReward);

      return true;
    }

    /**
        @dev - For unsuccessful submission, the Roto will initially sent back to the contract.
        @param _user address, the address of the user who's stake was unsuccessful
        @param _tournamentID 32byte hex, the tournament which the stake belongs to
        @return - whether the roto was successfully destroyed
     */
    function destroyRoto(address _user, bytes32 _tournamentID) external onlyOwner stopInEmergency returns(bool successful) {
        Tournament storage tournament = tournaments[_tournamentID];
        require(tournament.open==true);

        Stake storage user_stake = tournament.stakes[_user][_tournamentID];

        uint256 initial_stake = user_stake.amount;

        require(initial_stake > 0);
        require(user_stake.resolved == false);

        user_stake.amount = 0;
        user_stake.resolved = true;
        user_stake.successful = false;

        assert(token.destroyRoto(_user, _tournamentID));
        tournament.stakesResolved = tournament.stakesResolved.add(1);

        emit StakeDestroyed(_tournamentID, _user, initial_stake);

        return true;
    }

    /**
        @dev - The public method which will allow user's to stake their Roto alongside their submissions
        @param _value the amount of Roto being staked, the id of that stake, and the id of the tournament
        @return - whether the staking request was successful
     */
    function stake(uint256 _value, bytes32 _tournamentID) external stopInEmergency returns(bool successful) {
        return _stake(msg.sender, _tournamentID, _value);
    }

    /**
        @dev - The internal method to process the request to stake Roto as a part of the Tournament Submission
        @param _staker the user who's staking roto, the ID of the tournament, the amount of roto the user's staking, the staking tag
        @return - whether the withdraw operation was successful
     */
    function _stake(address _staker, bytes32 _tournamentID, uint256 _value) internal returns(bool successful) {
        Tournament storage tournament = tournaments[_tournamentID];

        //The User can't submit after tournament closure and the tournament must have begun
        require((tournament.open==true));
        require(tournament.etherPrize>0);
        
        Stake storage user_stake = tournament.stakes[_staker][_tournamentID];
        
        require(user_stake.amount==0); // Users can only stake once
        require(_value>0); // Users must stake at least 1 ROTO
        require(_staker != roto && _staker != owner); //RotoHive can't stake in tournament
        
        //Users must have the necessary balances to submit their stake
        assert(token.canStake(_staker, _value));

        user_stake.amount = _value;
        assert(token.stakeRoto(_staker,_tournamentID,_value));

        // adds the stake the submission
        tournament.userStakes = tournament.userStakes.add(1);

        emit StakeProcessed(_staker, user_stake.amount, _tournamentID);

        return true;
    }

    /**
        @dev - Allows RotoHive to create this week's RotoHive Tournament
        @param _tournamentID 32byte hex, the ID which RotoHive uses to reference each tournament
        @param _etherPrize Eth, the total ether prize pool for the tournament
        @param _rotoPrize ROTO, the total ROTO prize pool for the tournament
        @return - whether the tournament was successfully created
     */
    function createTournament(bytes32 _tournamentID, uint256 _etherPrize, uint256 _rotoPrize) external payable onlyOwner returns(bool successful) {
        Tournament storage newTournament = tournaments[_tournamentID];
        require(newTournament.creationTime==0);
        
        newTournament.open = true;
        newTournament.etherPrize = _etherPrize;
        newTournament.etherLeft = _etherPrize;

        newTournament.rotoPrize = _rotoPrize;
        newTournament.rotoLeft = _rotoPrize;
        newTournament.creationTime = block.timestamp;

        emit TournamentCreated(_tournamentID, _etherPrize, _rotoPrize);

        return true;
    }

    /**
      @dev - closes the current tournament after the submission deadline has passed
      @param _tournamentID the tournament ID
      @return - returns whether the tournament was closed successfully
    */
    function closeTournament(bytes32 _tournamentID) external onlyOwner returns(bool successful) {
       Tournament storage tournament = tournaments[_tournamentID];
      //  the tournament should be open
       require(tournament.open==true);

       //  all the prizes should have been given out
       require(tournament.rotoLeft == 0 && tournament.etherLeft == 0);
      //  all the users stakes should have been resolved
       require(tournament.userStakes == tournament.stakesResolved);
       tournament.open = false;

       emit TournamentClosed(_tournamentID);
       return true;
    }
}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[{"name":"_emergency","type":"bool"}],"name":"setEmergency","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"tournaments","outputs":[{"name":"open","type":"bool"},{"name":"etherPrize","type":"uint256"},{"name":"etherLeft","type":"uint256"},{"name":"rotoPrize","type":"uint256"},{"name":"rotoLeft","type":"uint256"},{"name":"creationTime","type":"uint256"},{"name":"userStakes","type":"uint256"},{"name":"stakesResolved","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_tournamentID","type":"bytes32"},{"name":"_rotoReward","type":"uint256"}],"name":"rewardRoto","outputs":[{"name":"successful","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_tournamentID","type":"bytes32"}],"name":"destroyRoto","outputs":[{"name":"successful","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tournamentID","type":"bytes32"}],"name":"closeTournament","outputs":[{"name":"successful","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_tournamentID","type":"bytes32"},{"name":"_etherReward","type":"uint256"}],"name":"releaseRoto","outputs":[{"name":"successful","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"},{"name":"_tournamentID","type":"bytes32"}],"name":"stake","outputs":[{"name":"successful","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"changeOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_contract","type":"address"}],"name":"setTokenContract","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tournamentID","type":"bytes32"},{"name":"_etherPrize","type":"uint256"},{"name":"_rotoPrize","type":"uint256"}],"name":"createTournament","outputs":[{"name":"successful","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"staker","type":"address"},{"indexed":false,"name":"totalAmountStaked","type":"uint256"},{"indexed":true,"name":"tournamentID","type":"bytes32"}],"name":"StakeProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tournamentID","type":"bytes32"},{"indexed":true,"name":"stakerAddress","type":"address"},{"indexed":false,"name":"rotoLost","type":"uint256"}],"name":"StakeDestroyed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tournamentID","type":"bytes32"},{"indexed":true,"name":"stakerAddress","type":"address"},{"indexed":false,"name":"etherReward","type":"uint256"},{"indexed":false,"name":"rotoStaked","type":"uint256"}],"name":"StakeReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tournamentID","type":"bytes32"},{"indexed":true,"name":"stakerAddress","type":"address"},{"indexed":false,"name":"rotoReward","type":"uint256"}],"name":"SubmissionRewarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_contract","type":"address"}],"name":"TokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tournamentID","type":"bytes32"},{"indexed":false,"name":"etherPrize","type":"uint256"},{"indexed":false,"name":"rotoPrize","type":"uint256"}],"name":"TournamentCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tournamentID","type":"bytes32"}],"name":"TournamentClosed","type":"event"}]

608060405234801561001057600080fd5b5060038054600160a060020a0319163317905560048054600160a860020a03191630179055610e29806100446000396000f3006080604052600436106100a35763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630501d55681146100a8578063139cfab1146100d65780632f2d783e146101315780633cc136e0146101585780634f8d40e11461017c5780637515b84a1461019457806383c592cf146101bb578063a6f9dae1146101d6578063bbcd5bbe146101f7578063c6e68ea614610218575b600080fd5b3480156100b457600080fd5b506100c26004351515610229565b604080519115158252519081900360200190f35b3480156100e257600080fd5b506100ee600435610275565b6040805198151589526020890197909752878701959095526060870193909352608086019190915260a085015260c084015260e083015251908190036101000190f35b34801561013d57600080fd5b506100c2600160a060020a03600435166024356044356102bc565b34801561016457600080fd5b506100c2600160a060020a036004351660243561049f565b34801561018857600080fd5b506100c260043561066e565b3480156101a057600080fd5b506100c2600160a060020a036004351660243560443561071b565b3480156101c757600080fd5b506100c260043560243561097c565b3480156101e257600080fd5b506100c2600160a060020a03600435166109a8565b34801561020357600080fd5b506100c2600160a060020a03600435166109f3565b6100c2600435602435604435610aca565b600354600090600160a060020a0316331461024357600080fd5b506004805482151560a060020a0274ff0000000000000000000000000000000000000000199091161790556001919050565b6000602081905290815260409020805460018201546002830154600384015460048501546005860154600787015460089097015460ff909616969495939492939192909188565b600354600090819081908190600160a060020a031633146102dc57600080fd5b60045460a060020a900460ff16156102f357600080fd5b6000868152602081905260409020805490935060ff16151560011461031757600080fd5b5050600160a060020a0385166000908152600682016020908152604080832087845290915290208054801561034b57600080fd5b600483015485111561035c57600080fd5b6001820154610100900460ff161561037357600080fd5b6004830154610388908663ffffffff610b7616565b600480850191909155600154604080517faf8b0ec7000000000000000000000000000000000000000000000000000000008152600160a060020a038b811694820194909452602481018990529051929091169163af8b0ec7916044808201926020929091908290030181600087803b15801561040357600080fd5b505af1158015610417573d6000803e3d6000fd5b505050506040513d602081101561042d57600080fd5b5051151561043757fe5b6001828101805460ff1961ff001990911661010017169091179055604080518681529051600160a060020a0389169188917fbde63ce1e6c04dda93688217d96947e5dbc54f83174c152f3f9c0d3edbcf1b139181900360200190a35060019695505050505050565b600354600090819081908190600160a060020a031633146104bf57600080fd5b60045460a060020a900460ff16156104d657600080fd5b6000858152602081905260409020805490935060ff1615156001146104fa57600080fd5b5050600160a060020a03841660009081526006820160209081526040808320868452909152812080549091811161053057600080fd5b6001820154610100900460ff161561054757600080fd5b60008083556001808401805460ff1961ff00199091166101001716905554604080517f3cc136e0000000000000000000000000000000000000000000000000000000008152600160a060020a038a81166004830152602482018a905291519190921692633cc136e092604480820193602093909283900390910190829087803b1580156105d357600080fd5b505af11580156105e7573d6000803e3d6000fd5b505050506040513d60208110156105fd57600080fd5b5051151561060757fe5b600883015461061d90600163ffffffff610b8816565b6008840155604080518281529051600160a060020a0388169187917f049aae62612f34826b222570c2ac41863678a3e6d62c9232780a9e765728c8309181900360200190a350600195945050505050565b6003546000908190600160a060020a0316331461068a57600080fd5b506000828152602081905260409020805460ff1615156001146106ac57600080fd5b60048101541580156106c057506002810154155b15156106cb57600080fd5b60088101546007820154146106df57600080fd5b805460ff1916815560405183907f5355d47307d9c003c99b9b30cc5f1ce29148397f91ce2084b17609819517df3290600090a250600192915050565b600354600090819081908190600160a060020a0316331461073b57600080fd5b60045460a060020a900460ff161561075257600080fd5b6000868152602081905260409020805490935060ff16151560011461077657600080fd5b5050600160a060020a0385166000908152600682016020908152604080832087845290915281208054909181116107ac57600080fd5b6001820154610100900460ff16156107c357600080fd5b600454600160a060020a03163185106107db57600080fd5b60028301548511156107ec57600080fd5b6000808355600154604080517fd560f696000000000000000000000000000000000000000000000000000000008152600160a060020a038b81166004830152602482018b90529151919092169263d560f69692604480820193602093909283900390910190829087803b15801561086257600080fd5b505af1158015610876573d6000803e3d6000fd5b505050506040513d602081101561088c57600080fd5b5051151561089657fe5b60088301546108ac90600163ffffffff610b8816565b60088401556001828101805460ff1961ff00199091166101001716909117905560008511156109275760028301546108ea908663ffffffff610b7616565b6002840155604051600160a060020a0388169086156108fc029087906000818181858888f19350505050158015610925573d6000803e3d6000fd5b505b60408051868152602081018390528151600160a060020a038a169289927fd6459a26cb873a02b48d26eccd0e961093a710ac5b58b4a00239af14fe4996ba929081900390910190a35060019695505050505050565b60045460009060a060020a900460ff161561099657600080fd5b6109a1338385610b9b565b9392505050565b600354600090600160a060020a031633146109c257600080fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03939093169290921790915590565b6003546000908190600160a060020a03163314610a0f57600080fd5b600160a060020a03831615801590610a355750600454600160a060020a03848116911614155b1515610a4057600080fd5b50813b60008111610a5057600080fd5b60028054600160a060020a0380861673ffffffffffffffffffffffffffffffffffffffff19928316811793849055600180549093169390911692909217905560408051918252517f5d108ca248943e98e1886bbc2c38beda701271994a14354258a11692b81b73cf9181900360200190a150600192915050565b6003546000908190600160a060020a03163314610ae657600080fd5b506000848152602081905260409020600581015415610b0457600080fd5b805460ff19166001908117825581018490556002810184905560038101839055600481018390554260058201556040805185815260208101859052815187927f687ecf6345d4ba10d46bd9b936e3521c4bdcd9051e4c43523f0bbfde7a271907928290030190a2506001949350505050565b600082821115610b8257fe5b50900390565b81810182811015610b9557fe5b92915050565b60008281526020819052604081208054829060ff161515600114610bbe57600080fd5b6001820154600010610bcf57600080fd5b50600160a060020a038516600090815260068201602090815260408083208784529091529020805415610c0157600080fd5b60008411610c0e57600080fd5b600254600160a060020a03878116911614801590610c3a5750600354600160a060020a03878116911614155b1515610c4557600080fd5b600154604080517f2afbbacb000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301526024820188905291519190921691632afbbacb9160448083019260209291908290030181600087803b158015610cb457600080fd5b505af1158015610cc8573d6000803e3d6000fd5b505050506040513d6020811015610cde57600080fd5b50511515610ce857fe5b838155600154604080517f362f8833000000000000000000000000000000000000000000000000000000008152600160a060020a03898116600483015260248201899052604482018890529151919092169163362f88339160648083019260209291908290030181600087803b158015610d6157600080fd5b505af1158015610d75573d6000803e3d6000fd5b505050506040513d6020811015610d8b57600080fd5b50511515610d9557fe5b6007820154610dab90600163ffffffff610b8816565b6007830155805460408051918252518691600160a060020a038916917fce5d2d53b298e573a854cfbe9cc8529dd41b53aff08f3ac4bcc705e50c18468a9181900360200190a3506001959450505050505600a165627a7a72305820402566a6dee5120928d74c6c59b11374b0fbd1730fcd22f799dac7680a183c810029

Deployed Bytecode

0x6080604052600436106100a35763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630501d55681146100a8578063139cfab1146100d65780632f2d783e146101315780633cc136e0146101585780634f8d40e11461017c5780637515b84a1461019457806383c592cf146101bb578063a6f9dae1146101d6578063bbcd5bbe146101f7578063c6e68ea614610218575b600080fd5b3480156100b457600080fd5b506100c26004351515610229565b604080519115158252519081900360200190f35b3480156100e257600080fd5b506100ee600435610275565b6040805198151589526020890197909752878701959095526060870193909352608086019190915260a085015260c084015260e083015251908190036101000190f35b34801561013d57600080fd5b506100c2600160a060020a03600435166024356044356102bc565b34801561016457600080fd5b506100c2600160a060020a036004351660243561049f565b34801561018857600080fd5b506100c260043561066e565b3480156101a057600080fd5b506100c2600160a060020a036004351660243560443561071b565b3480156101c757600080fd5b506100c260043560243561097c565b3480156101e257600080fd5b506100c2600160a060020a03600435166109a8565b34801561020357600080fd5b506100c2600160a060020a03600435166109f3565b6100c2600435602435604435610aca565b600354600090600160a060020a0316331461024357600080fd5b506004805482151560a060020a0274ff0000000000000000000000000000000000000000199091161790556001919050565b6000602081905290815260409020805460018201546002830154600384015460048501546005860154600787015460089097015460ff909616969495939492939192909188565b600354600090819081908190600160a060020a031633146102dc57600080fd5b60045460a060020a900460ff16156102f357600080fd5b6000868152602081905260409020805490935060ff16151560011461031757600080fd5b5050600160a060020a0385166000908152600682016020908152604080832087845290915290208054801561034b57600080fd5b600483015485111561035c57600080fd5b6001820154610100900460ff161561037357600080fd5b6004830154610388908663ffffffff610b7616565b600480850191909155600154604080517faf8b0ec7000000000000000000000000000000000000000000000000000000008152600160a060020a038b811694820194909452602481018990529051929091169163af8b0ec7916044808201926020929091908290030181600087803b15801561040357600080fd5b505af1158015610417573d6000803e3d6000fd5b505050506040513d602081101561042d57600080fd5b5051151561043757fe5b6001828101805460ff1961ff001990911661010017169091179055604080518681529051600160a060020a0389169188917fbde63ce1e6c04dda93688217d96947e5dbc54f83174c152f3f9c0d3edbcf1b139181900360200190a35060019695505050505050565b600354600090819081908190600160a060020a031633146104bf57600080fd5b60045460a060020a900460ff16156104d657600080fd5b6000858152602081905260409020805490935060ff1615156001146104fa57600080fd5b5050600160a060020a03841660009081526006820160209081526040808320868452909152812080549091811161053057600080fd5b6001820154610100900460ff161561054757600080fd5b60008083556001808401805460ff1961ff00199091166101001716905554604080517f3cc136e0000000000000000000000000000000000000000000000000000000008152600160a060020a038a81166004830152602482018a905291519190921692633cc136e092604480820193602093909283900390910190829087803b1580156105d357600080fd5b505af11580156105e7573d6000803e3d6000fd5b505050506040513d60208110156105fd57600080fd5b5051151561060757fe5b600883015461061d90600163ffffffff610b8816565b6008840155604080518281529051600160a060020a0388169187917f049aae62612f34826b222570c2ac41863678a3e6d62c9232780a9e765728c8309181900360200190a350600195945050505050565b6003546000908190600160a060020a0316331461068a57600080fd5b506000828152602081905260409020805460ff1615156001146106ac57600080fd5b60048101541580156106c057506002810154155b15156106cb57600080fd5b60088101546007820154146106df57600080fd5b805460ff1916815560405183907f5355d47307d9c003c99b9b30cc5f1ce29148397f91ce2084b17609819517df3290600090a250600192915050565b600354600090819081908190600160a060020a0316331461073b57600080fd5b60045460a060020a900460ff161561075257600080fd5b6000868152602081905260409020805490935060ff16151560011461077657600080fd5b5050600160a060020a0385166000908152600682016020908152604080832087845290915281208054909181116107ac57600080fd5b6001820154610100900460ff16156107c357600080fd5b600454600160a060020a03163185106107db57600080fd5b60028301548511156107ec57600080fd5b6000808355600154604080517fd560f696000000000000000000000000000000000000000000000000000000008152600160a060020a038b81166004830152602482018b90529151919092169263d560f69692604480820193602093909283900390910190829087803b15801561086257600080fd5b505af1158015610876573d6000803e3d6000fd5b505050506040513d602081101561088c57600080fd5b5051151561089657fe5b60088301546108ac90600163ffffffff610b8816565b60088401556001828101805460ff1961ff00199091166101001716909117905560008511156109275760028301546108ea908663ffffffff610b7616565b6002840155604051600160a060020a0388169086156108fc029087906000818181858888f19350505050158015610925573d6000803e3d6000fd5b505b60408051868152602081018390528151600160a060020a038a169289927fd6459a26cb873a02b48d26eccd0e961093a710ac5b58b4a00239af14fe4996ba929081900390910190a35060019695505050505050565b60045460009060a060020a900460ff161561099657600080fd5b6109a1338385610b9b565b9392505050565b600354600090600160a060020a031633146109c257600080fd5b6003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03939093169290921790915590565b6003546000908190600160a060020a03163314610a0f57600080fd5b600160a060020a03831615801590610a355750600454600160a060020a03848116911614155b1515610a4057600080fd5b50813b60008111610a5057600080fd5b60028054600160a060020a0380861673ffffffffffffffffffffffffffffffffffffffff19928316811793849055600180549093169390911692909217905560408051918252517f5d108ca248943e98e1886bbc2c38beda701271994a14354258a11692b81b73cf9181900360200190a150600192915050565b6003546000908190600160a060020a03163314610ae657600080fd5b506000848152602081905260409020600581015415610b0457600080fd5b805460ff19166001908117825581018490556002810184905560038101839055600481018390554260058201556040805185815260208101859052815187927f687ecf6345d4ba10d46bd9b936e3521c4bdcd9051e4c43523f0bbfde7a271907928290030190a2506001949350505050565b600082821115610b8257fe5b50900390565b81810182811015610b9557fe5b92915050565b60008281526020819052604081208054829060ff161515600114610bbe57600080fd5b6001820154600010610bcf57600080fd5b50600160a060020a038516600090815260068201602090815260408083208784529091529020805415610c0157600080fd5b60008411610c0e57600080fd5b600254600160a060020a03878116911614801590610c3a5750600354600160a060020a03878116911614155b1515610c4557600080fd5b600154604080517f2afbbacb000000000000000000000000000000000000000000000000000000008152600160a060020a0389811660048301526024820188905291519190921691632afbbacb9160448083019260209291908290030181600087803b158015610cb457600080fd5b505af1158015610cc8573d6000803e3d6000fd5b505050506040513d6020811015610cde57600080fd5b50511515610ce857fe5b838155600154604080517f362f8833000000000000000000000000000000000000000000000000000000008152600160a060020a03898116600483015260248201899052604482018890529151919092169163362f88339160648083019260209291908290030181600087803b158015610d6157600080fd5b505af1158015610d75573d6000803e3d6000fd5b505050506040513d6020811015610d8b57600080fd5b50511515610d9557fe5b6007820154610dab90600163ffffffff610b8816565b6007830155805460408051918252518691600160a060020a038916917fce5d2d53b298e573a854cfbe9cc8529dd41b53aff08f3ac4bcc705e50c18468a9181900360200190a3506001959450505050505600a165627a7a72305820402566a6dee5120928d74c6c59b11374b0fbd1730fcd22f799dac7680a183c810029

Swarm Source

bzzr://402566a6dee5120928d74c6c59b11374b0fbd1730fcd22f799dac7680a183c81

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.