コード例 #1
0
ファイル: token_erc20_tas.py プロジェクト: taschain/taschain
 def burn(self, _value):
     #检查账户余额
     require(self.balanceOf[msg.sender] >= _value)
     self.balanceOf[msg.sender] -= _value
     self.totalSupply -= _value
     Event.emit("Burn", msg.sender, _value)
     return True
コード例 #2
0
 def mint_token(self, target, minted_amount):
     check_owner()
     if target not in self.balanceOf:
         self.balanceOf[target] = 0
     self.balanceOf[target] += minted_amount
     self.totalSupply += minted_amount
     Event.emit("Transfer", 0, this, minted_amount)
     Event.emit("Transfer", this, target, minted_amount)
コード例 #3
0
ファイル: token_erc20_tas.py プロジェクト: taschain/taschain
 def burnFrom(self, _from, _value):
     # if _from not in self.balanceOf:
     #     self.balanceOf[_from] = 0
     #检查账户余额
     require(self.balanceOf[_from] >= _value)
     require(_value <= self.allowance[_from][msg.sender])
     self.balanceOf[_from] -= _value
     self.allowance[_from][msg.sender] -= _value
     self.totalSupply -= _value
     Event.emit("Burn", _from, _value)
     return True
コード例 #4
0
    def bet(self, one_bet_option, one_round_id):
        print(msg.sender)
        send_key = msg.sender + str(one_round_id)
        one_game = self.games.get(send_key)
        if one_game is not None:
            return
        one_game_round = GameRound()
        one_game_round.roundId = one_round_id
        one_game_round.stake = msg.value
        one_game_round.betOption = one_bet_option

        self.games[send_key] = one_game_round.__dict__
        print(self.games)
        Event.emit("bet", 0, this, one_game_round.stake)
コード例 #5
0
ファイル: token_erc20_tas.py プロジェクト: taschain/taschain
 def _transfer(self, _from, _to, _value):
     if _to not in self.balanceOf:
         self.balanceOf[_to] = 0
     if _from not in self.balanceOf:
         self.balanceOf[_from] = 0
     # 接收账户地址是否合法
     require(Address(_to).invalid())
     # 账户余额是否满足转账金额
     require(self.balanceOf[_from] >= _value)
     # 检查转账金额是否合法
     require(_value > 0)
     # 转账
     self.balanceOf[_from] -= _value
     self.balanceOf[_to] += _value
     Event.emit("Transfer", _from, _to, _value)
コード例 #6
0
    def settle(self, player_address, one_round_id, banker_point, player_point):
        send_key = player_address + str(one_round_id)
        one_game = self.games.get(send_key)
        print(self.games)
        print(one_game)
        if one_game is None:
            return
        if one_game.get("isSettled"):
            return
        one_game["bankerPoint"] = banker_point
        one_game["player_point"] = player_point
        self._determine_result(one_game)
        self._determine_loss(one_game)

        account.transfer(player_address, one_game["winLoss"])
        one_game["isSettled"] = True
        Event.emit("settle", 0, this, one_game["winLoss"])
コード例 #7
0
ファイル: token_erc20_tas.py プロジェクト: taschain/taschain
 def approve(self, _spender, _value):
     if msg.sender not in self.allowance:
         self.allowance[msg.sender] = {}
     self.allowance[msg.sender][_spender] = _value
     Event.emit("Approval", msg.sender, _spender, _value)
     return True
コード例 #8
0
 def freeze_account(self, target, freeze):
     check_owner()
     self.frozenAccount[target] = freeze
     Event.emit("FrozenFunds", target, freeze)