SmartDice Loading

... LOADING ...



X 23.9876


5 %









Player Address
Bet Amount

Earn 1% Reward From Win Bets of Friends!

Invite Your Friends to Play SmartDice

Your Current Earnings

0.3453 Eth

Click to Withdraw

How Does It Work?

Simply share above link to your friends.

When your friends wins, you will earn 1% reward of each bet profit!

Please login Metamask to get share links

SmartDice contract is here

pragma solidity ^0.4.18; import ""; /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ contract SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } } /** * @title DiceGame * @dev Dice Betting contract using Oraclize, inherited Ownable and SafeMath */ contract SmartDice is usingOraclize, Ownable, SafeMath { struct DiceBet { address player; address referee; uint odd; uint stake; uint rng; uint profit; uint win; bool paid; } struct Ref { uint refCnt; uint balance; } mapping (bytes32 => DiceBet) public bets; mapping (address => Ref) public refWallet; mapping (address => uint) pendingWallet; mapping (uint => uint) maxBetAmounts; bytes32[] public queryIds; uint public constant baseNumber = 1000; uint public totalBets; uint public totalUserProfit; uint public totalUserLost; uint public totalWins; uint public totalLosts; uint public houseEdge; uint public refShare; uint public balance; uint public maxPendingBalances; uint public minBetAmount; uint public gasOraclize; uint public gasPriceOraclize; event DiceRolled(address _address, bytes32 _queryId, uint _amount, uint _odd, address _referee); event UserWin(address _address, bytes32 _queryId, uint _amount, uint _odd, uint _randomResult, uint _profit, address _referee); event UserLose(address _address, bytes32 _queryId, uint _amount, uint _odd, uint _randomResult, uint _lost); event HouseDeposited(uint _amount); event HouseWithdrawed(address _withdraw, uint _amount); event PaidPendingBalance(address _holder, uint _amount); event PaidRefBalance(address _holder, uint _amount); event ResetHouseEdge(); modifier onlyOraclize() { require (msg.sender == oraclize_cbAddress()); _; } function SmartDice() public { oraclize_setNetwork(networkID_auto); oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS); houseEdge = 96; // 100 - fee(4%) refShare = 1; gasOraclize = 500000; minBetAmount = 100 finney; maxBetAmounts[10] = 500 finney; maxBetAmounts[20] = 1 ether; maxBetAmounts[30] = 2 ether; maxBetAmounts[40] = 4 ether; maxBetAmounts[50] = 3 ether; maxBetAmounts[60] = 2 ether; gasPriceOraclize = 20000000000 wei; oraclize_setCustomGasPrice(gasPriceOraclize); } function __callback(bytes32 myId, string result, bytes proof) public onlyOraclize { require(bets[myId].player != address(0x0)); require(bets[myId].win == 2); bets[myId].rng = uint(keccak256(parseInt(result), proof)) % baseNumber + 1; maxPendingBalances = sub(maxPendingBalances, bets[myId].profit); if (bets[myId].rng < bets[myId].odd * 10) { /// player win bets[myId].win = 1; totalWins = totalWins + 1; uint refAmt = 0; if (bets[myId].referee != address(0x0)) { refAmt = bets[myId].profit * refShare / 100; refWallet[bets[myId].referee].refCnt ++; refWallet[bets[myId].referee].balance = add(refWallet[bets[myId].referee].balance, refAmt); } balance = sub(balance, bets[myId].profit); totalUserProfit = totalUserProfit + bets[myId].profit; uint amtToSend = add(bets[myId].profit, bets[myId].stake) - refAmt; bets[myId].paid = true; if (!bets[myId].player.send(amtToSend)) { bets[myId].paid = false; pendingWallet[bets[myId].player] = add(pendingWallet[bets[myId].player], amtToSend); } UserWin(bets[myId].player, myId, bets[myId].stake, bets[myId].odd, bets[myId].rng, bets[myId].profit - refAmt, bets[myId].referee); } else { /// player defeated bets[myId].win = 0; balance = sub(balance, 1); totalUserLost = totalUserLost + bets[myId].stake; totalLosts = totalLosts + 1; bets[myId].profit = 0; bets[myId].paid = true; if (!bets[myId].player.send(1)) { bets[myId].paid = false; pendingWallet[bets[myId].player] = add(pendingWallet[bets[myId].player], 1); } balance = add(balance, bets[myId].stake); UserLose(bets[myId].player, myId, bets[myId].stake, bets[myId].odd, bets[myId].rng, bets[myId].stake); } } function rollDice(uint _odd, address _referee) public payable returns (bytes32) { require(_odd <= 60 && _odd > 0); require(maxBetAmounts[_odd] > 0 && msg.value <= maxBetAmounts[_odd]); require(msg.sender != _referee); uint oraclizeFee = OraclizeI(OAR.getAddress()).getPrice("URL", gasOraclize); if (minBetAmount + oraclizeFee >= msg.value) revert(); string memory payload = strConcat('\n{"jsonrpc":"2.0","method":"generateIntegers","params":{"apiKey":"14a9ea18-183d-4f06-95ad-de43293dbe0c","n":1,"min":1,"max":', uint2str(baseNumber), ',"replacement":true,"base":10},"id":"1"}'); bytes32 queryId = oraclize_query("URL", "json(", payload, gasOraclize); uint stake = msg.value - oraclizeFee; uint profit = stake * houseEdge / _odd - stake; bets[queryId] = DiceBet(msg.sender, _referee, _odd, stake, 0, profit, 2, false); queryIds.push(queryId); maxPendingBalances = add(maxPendingBalances, profit); if (maxPendingBalances > balance) revert(); totalBets += 1; DiceRolled(msg.sender, queryId, stake, _odd, _referee); return queryId; } function getPendingBalance(address holder) public view returns (uint) { return balances[holder]; } function setOraclizeGasLimit(uint amount) public onlyOwner { gasOraclize = amount; } function setOraclizeGasPrice(uint price) public onlyOwner { gasPriceOraclize = price; oraclize_setCustomGasPrice(price); } function getMinBetAmount() public constant returns (uint) { uint oraclizeFee = OraclizeI(OAR.getAddress()).getPrice("URL", gasOraclize); return oraclizeFee + minBetAmount; } function getMaxBetAmount(uint odd) public constant returns (uint) { uint totalBalance = address(this).balance; uint oraclizeFee = OraclizeI(OAR.getAddress()).getPrice("URL", gasOraclize); return totalBalance * odd * 100 / (houseEdge * (100 - odd)) + oraclizeFee; } function getBetCount() public constant returns (uint) { return queryIds.length; } function getBet(uint _id) public constant returns (address, uint, uint, uint, uint, uint, bool) { require(_id < queryIds.length); bytes32 qId = queryIds[_id]; if (bets[qId].stake > 0) { DiceBet memory bet = bets[qId]; return (bet.player, bet.stake, bet.odd, bet.rng, bet.profit,, bet.paid); } } function getRefWallet() public constant returns (uint, uint) { return (refWallet[msg.sender].refCnt, refWallet[msg.sender].balance); } function getContractData() public constant returns (uint, uint, uint, uint, uint, uint, uint, uint) { uint totalBalance = address(this).balance; uint oraclizeFee = OraclizeI(OAR.getAddress()).getPrice("URL", gasOraclize); return (totalBalance, oraclizeFee, totalBets, totalUserProfit, totalUserLost, totalWins, totalLosts, houseEdge); } function setMinBetAmount(uint amount) public onlyOwner { minBetAmount = amount; } function setMaxBetAmount(uint odd, uint amount) public onlyOwner { require(maxBetAmounts[odd] > 0); maxBetAmounts[odd] = amount; } function setHouseEdge(uint value) public onlyOwner { houseEdge = value; ResetHouseEdge(); } function setRefShare(uint value) public onlyOwner { refShare = value; } function depositBalance() public payable onlyOwner { balance = add(balance, msg.value); HouseDeposited(msg.value); } function resetBalance() public onlyOwner { balance = address(this).balance; } function withdrawBalance(address withdraw, uint amount) public onlyOwner { require(withdraw != address(0)); balance = sub(this.balance(), amount); if (!withdraw.send(amount)) revert(); HouseWithdrawed(withdraw, amount); } function withdrawPendingBalance(address holder) public onlyOwner { require(holder != address(0)); require(balances[holder] != 0); uint amount = balances[holder]; balances[holder] = 0; if (!holder.send(amount)) revert(); PaidPendingBalance(holder, amount); } function withdrawRefBalance() public { require(refWallet[msg.sender].balance > 0); uint amount = refWallet[msg.sender].balance; refWallet[msg.sender].balance = 0; balance = sub(balance, amount); if (!msg.sender.send(amount)) revert(); PaidRefBalance(msg.sender, amount); } function destroy() public onlyOwner { selfdestruct(owner); } }


SmartDice is a smart-contract-driven dice gambling application.

SmartDice generate random number from via Oraclize.

House edge 4% will be charged for winning users.

There is not 3rd party to generate or control random number, so its a pure trust in meaning.

Users don't have to sign up nor deposit Ethereum on the platform.

All you need is to install MetaMask on your Chrome browser and unlock it.

SmartDice has a vision to conquoer blockchain based gambling world.

The SmartDice is a kickstart of an ambitious project and we will provide seamless updates as time being.

We have a mission to apply instance payment channels like Raiden network so that you can have a prompt dice, much faster than traditional bettings.

Our next smart contract based decentralized betting apps such as Lottery, Roulette, Slot are coming soon.

Particularly we are going to apply Raiden network for fast transactions in our betting apps.

We are doing our best to provide you best experience and convenience, and outstanding betting dapps.

For any questions or complains, please contact us here or subscribe to our Telegram channel. We are all hands on the desk for you. Have a fun thanks to blockchain technology!

1. You need to make sure you have MetaMask installed on your Chrome browser, and unlocked it.

2. Choose a card you will bet on in the gallery.

The value of percent implies probability that you could win in the contract.

If you choose one card from the gallery, you will see detailed betting information below of gallery. The less probability you choose, the more profit you may get from the contract.

In below information, you can check how much profit you could get from the contract. Please make sure your possible profit/lost.

3. Input bet amount and click below button

The amount will be deduced by Oraclize fee, so your actual bet amount will be slightly less than you inputed.

Once you input bet amount, the next label indicates possible profit for the amount.

When MetaMask notifies you will need to click "Submit" button of MetaMask.

A progress popup will show your current working progress and bet result.

If the lucky number is below than the odd you chosen, you win! If not, you will lose...

Please note that you should not refresh your browser or close the popup.

Smart Dice Team.


For any request or suggestions will help us to close to our vision

We are all hands on desk to hear your voice

Please send us email here

Join us

Smart Dice Team

Good Luck

Please don't close your browser while rolling

SmartDice Betting
Sending Transaction to smart contract (30 seconds...)
SmartDice Betting
SmartDice Betting
Waiting random number (60 seconds...)
SmartDice Betting
SmartDice Betting
You won