contract GlobalRentalToken is ERC20Interface, Owned {
    using SafeMath for uint256;
    string public symbol = "GRT";
    string public  name = "Global Rental Token";
    uint256 public decimals = 8;
    uint256 _totalSupply = 9e9* 10 ** uint(decimals);
    
    mapping(address => uint256) balances;
    mapping(address => mapping(address => uint256)) allowed;
    
    mapping(address => walletDetail) walletsAllocation;

    struct walletDetail{
        uint256 tokens;
        bool lock;
    }

    // ------------------------------------------------------------------------
    // Constructor
    // ------------------------------------------------------------------------
    constructor() public {
        owner = address(0x736c327e2D2609f4C8f04F7EDc859efB47A09A34);
        balances[address(this)] = totalSupply();
        emit Transfer(address(0),address(this), totalSupply());

        _makeAllocations();
    }

 function _makeAllocations() private{
        //Team Wallet (Locted 2 years)
        _transfer (0x80109a3F80E15f73D84eF3b93B645B52e5664d42, 2e9 * 10 ** uint(decimals));
        walletsAllocation [0x80109a3F80E15f73D84eF3b93B645B52e5664d42] = walletDetail(2e9 * 10 ** uint(decimals), false);
        //Development Wallet (Locted 1 year)
        _transfer (0x2941DbaAD206381DE71433fef63Fe4245dfc8D6b, 3e9 * 10 ** uint(decimals));
        walletsAllocation [0x2941DbaAD206381DE71433fef63Fe4245dfc8D6b] = walletDetail(3e9 * 10 ** uint(decimals), false);
        //Airdrop&Marketing Wallet
        _transfer (0x9df33769022349F3EBcA7bBc74ceB54D352aD488, 4e9 * 10 ** uint(decimals));
        walletsAllocation [0x9df33769022349F3EBcA7bBc74ceB54D352aD488] = walletDetail(4e9 * 10 ** uint(decimals), false);
    }
    
    /** ERC20Interface function's implementation **/
    
    function totalSupply() public view returns (uint256){
       return _totalSupply; 
    }
    
    // ------------------------------------------------------------------------
    // Get the token balance for account `tokenOwner`
    // ------------------------------------------------------------------------
    function balanceOf(address tokenOwner) public view returns (uint256 balance) {
        return balances[tokenOwner];
    }

    // ------------------------------------------------------------------------
    // Transfer the balance from token owner's account to `to` account
    // - Owner's account must have sufficient balance to transfer
    // - 0 value transfers are allowed
    // ------------------------------------------------------------------------
    function transfer(address to, uint256 tokens) public returns (bool success) {
        // prevent transfer to 0x0, use burn instead
        require(address(to) != address(0));
        require(balances[msg.sender] >= tokens );
        require(balances[to] + tokens >= balances[to]);

        balances[msg.sender] = balances[msg.sender].sub(tokens);
        balances[to] = balances[to].add(tokens);
        emit Transfer(msg.sender,to,tokens);
        return true;
    }
    
    // ------------------------------------------------------------------------
    // Token owner can approve for `spender` to transferFrom(...) `tokens`
    // from the token owner's account
    // ------------------------------------------------------------------------
    function approve(address spender, uint256 tokens) public returns (bool success){
        allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender,spender,tokens);
        return true;
    }

    // ------------------------------------------------------------------------
    // Transfer `tokens` from the `from` account to the `to` account
    // 
    // The calling account must already have sufficient tokens approve(...)-d
    // for spending from the `from` account and
    // - From account must have sufficient balance to transfer
    // - Spender must have sufficient allowance to transfer
    // - 0 value transfers are allowed
    // ------------------------------------------------------------------------
    function transferFrom(address payable from, address to, uint256 tokens) public returns (bool success){
        require(tokens <= allowed[from][msg.sender]); //check allowance
        require(balances[from] >= tokens);

        balances[from] = balances[from].sub(tokens);
        balances[to] = balances[to].add(tokens);
        allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
        emit Transfer(from,to,tokens);
        return true;
    }
    
    // ------------------------------------------------------------------------
    // Returns the amount of tokens approved by the owner that can be
    // transferred to the spender's account
    // ------------------------------------------------------------------------
    function allowance(address tokenOwner, address spender) public view returns (uint256 remaining) {
        return allowed[tokenOwner][spender];
    }
    
    function transferFromContract(address to, uint256 tokens) public onlyOwner returns (bool success){
        _transfer(to,tokens);
        return true;
    }

    function _transfer(address to, uint256 tokens) internal {
        // prevent transfer to 0x0, use burn instead
        require(address(to) != address(0));
        require(balances[address(this)] >= tokens );
        require(balances[to] + tokens >= balances[to]);
        
        balances[address(this)] = balances[address(this)].sub(tokens);
        balances[to] = balances[to].add(tokens);
        emit Transfer(address(this),to,tokens);
    }

    function openLock(address _address) public onlyOwner{
        // open lock and transfer to respective address
        require(walletsAllocation[_address].lock);
        require(walletsAllocation[_address].tokens > 0);
        require(balances[_address] == 0);

        _transfer(_address, walletsAllocation[_address].tokens);
        walletsAllocation[_address].lock = false;
    }
    
    // ------------------------------------------------------------------------
    // Don't Accepts ETH
    // ------------------------------------------------------------------------
    function () external payable {
        revert();
    }
}
// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ----------------------------------------------------------------------------
function transferFrom(address payable from, address to, uint256 tokens) public returns (bool success){
    require(tokens <= allowed[from][msg.sender]); //check allowance
    require(balances[from] >= tokens);

    balances[from] = balances[from].sub(tokens);
    balances[to] = balances[to].add(tokens);
    allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens);
    emit Transfer(from,to,tokens);
    return true;
}

// ------------------------------------------------------------------------
// Transfer `tokens` from the `from` account to the `to` account
// 
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the `from` account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------