新DApp《VITE翻倍乐》申请上线


  • SBP Reward

    1.DApp的名称:VITE翻倍乐/VITE To The Moon

    2.DApp的介绍:
    游戏介绍:
    一款简单的猜数字游戏,该数字在游戏中为“倍率”,猜中即按相应用倍率进行奖励。

    游戏规则:
    每次投注前设定投注倍率,最低为1.01倍,最高为99.99倍,游戏出现的结果在0或1.01-99.99倍之间随机,倍率随机数概率与投注玩家以及金额大小均无关系。每次投注以后,开奖倍率大于等于投注倍率时,表示中奖,会根据投注的倍率获得奖励,开奖倍率小于投注倍率则表示未中奖,投注的VITE将不会返还。
    例如,投注10 VITE,倍率设定为1.8,如果开奖结果为1.8或更高,则用户将获得10 * 1.8,即18 的VITE奖励。

    3.上线状态:否

    4.DApp的合约地址:vite_8a50b500773c7abe0ceeb7e6e25a97871868585159d8333cc0
    合约认证链接:https://explorer.vite.net/account/vite_8a50b500773c7abe0ceeb7e6e25a97871868585159d8333cc0

    5.合约代码如下:

    pragma soliditypp ^0.4.2;
    contract ViteBet{
        address owner;
    
        struct BetLimit {
            uint256 lowerLimit;
            uint256 upperLimit;
            bool onActivated;
        }
    
        tokenId[] tokens = ["tti_5649544520544f4b454e6e40"];
        mapping(tokenId => BetLimit) public tokenMap;
        uint16[8] configArray = [360, 2030, 290, 155, 60, 50, 28, 27];
        uint16[9] configArray2 = [0, 101, 133, 600, 1000, 2000, 3000, 6000, 9999];
        uint16 top = 3000;
    
        event win(address indexed addr, uint256 rollTarget, uint256 betAmount, uint256 rollNum, uint256 winAmount);
        event lose(address indexed addr, uint256 rollTarget, uint256 betAmount, uint256 rollNum);
        event suspendBet(address indexed addr, uint256 rollTarget, uint256 betAmount);
    
        constructor() public {
            owner = msg.sender;
            tokenMap["tti_5649544520544f4b454e6e40"].lowerLimit = 1 vite;
            tokenMap["tti_5649544520544f4b454e6e40"].upperLimit = 300 vite;
            tokenMap["tti_5649544520544f4b454e6e40"].onActivated = true;
        }
    
        onMessage () payable {
        }
    
        onMessage configBetLimit(uint256 ll, uint256 ul, bool onActivated) {
            require(owner == msg.sender);
            require(ll > 0 && ll <= ul);
            if (tokenMap[msg.tokenid].lowerLimit == 0)
                tokens.push(msg.tokenid);
            tokenMap[msg.tokenid].lowerLimit = ll;
            tokenMap[msg.tokenid].upperLimit = ul;
            tokenMap[msg.tokenid].onActivated = onActivated;
        }
    
        onMessage configBet(uint16 val0, uint16 val1, uint16 val2, uint16 top3) {
            require(owner == msg.sender);
            configArray[0] = val0;
            configArray[1] = val1;
            configArray[2] = val2;
            top = top3;
        }
    
        onMessage DrawMoney(uint256 amount) {
            require(owner == msg.sender);
            require(amount <= balance(msg.tokenid));
            msg.sender.transfer(msg.tokenid, amount);
        }
    
        getter getBetLimit(tokenId token) returns(uint256 ll, uint256 ul) {
            return (tokenMap[token].lowerLimit, tokenMap[token].upperLimit);
        }
        getter getBetConfig1() returns(uint16 val0, uint16 val1, uint16 val2) {
            return (configArray[0], configArray[1], configArray[2]);
        }
        getter getBetTop() returns(uint16) {
            return top;
        }
        getter getTokenList() returns(tokenId[] memory) {
            return tokens;
        }
        getter getOnActivated(tokenId token) returns(bool) {
            return tokenMap[token].onActivated;
        }
    
        onMessage BetAndRoll(uint16 rollTargets) payable {
    
            uint256 betAmount = msg.amount;
            address betAddr = msg.sender;
            uint256 ll = tokenMap[msg.tokenid].lowerLimit;
            uint256 ul = tokenMap[msg.tokenid].upperLimit;
    
            bool onActivated = tokenMap[msg.tokenid].onActivated;
    
            require(onActivated);
            require(ll > 0 && ll <= ul);
            require(betAmount >= ll && betAmount <= ul);
            require(rollTargets > 100 && rollTargets < 10000);
    
            uint64 randomNumber = random64();
    
            uint16 matchIndex = 0;
            uint16 totall = 0;
            uint64 y = randomNumber%top;
            
            if (y <= configArray[0]) {
                matchIndex = 0;
            } else {
    
                for (uint16 j = uint16(configArray.length-1); j >= 0; j--) {
                    
                    totall += configArray[j];
                    uint64 c = (top-totall);
                    if (y > c) {
                        matchIndex = j;
                        break;
                    }
                }
            }
    
            uint64 rollNum = 0;        
            if (matchIndex > 0) {
                
                uint16 start = configArray2[matchIndex];
                uint16 end = configArray2[matchIndex+1];
                uint16 ab = end - start;
                
                rollNum = (randomNumber/10000)%ab;
                rollNum += start;
            }
    
            if (rollNum >= rollTargets) {
                uint256 winAmount = betAmount * rollTargets / 100;
                betAddr.transfer(msg.tokenid, winAmount);
                emit win(betAddr, rollTargets, betAmount, rollNum, winAmount);
            } else {
                emit lose(betAddr, rollTargets, betAmount, rollNum);
            }
        }
    
    }
    

Log in to reply
 

Suggested Topics