@Lawliet-N4Q-org said in 新DApp《VITE翻倍乐》申请上线: 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_d8f83ebc2e0c1312bf16b8ef172663688143bbd0f96d5b8f66 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[7] configArray = [300, 2100, 400, 210, 70, 70, 70]; uint16[8] configArray2 = [0, 101, 178, 500, 1000, 2000, 3000, 9999]; 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 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 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(); uint64 top = 0; for (uint64 i = 0; i < configArray.length; i++) { top += configArray[i]; } uint16 matchIndex = 0; uint16 totall = 0; for (uint16 j = uint16(configArray.length-1); j >= 0; j--) { uint16 tmp = configArray[j]; totall += tmp; uint64 c = (top-totall); uint64 y = randomNumber%top; if (y <= configArray[0]) { matchIndex = 0; break; } 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/1000000)%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); } } } VETERANVETERAN