⚠️ ⚠️ ⚠️ This explorer will be deprecated soon, please use PolygonScan.com

Contract Address Details

0xBe8F848595F01c2217BFee490a60F3C1FB703F83

dgSlots Last Balance Update: Block #15660925
Created by 0x1fcde1–2c0f8a at 0x7a7138–f7d749

Balance

0 MATIC

(@ /MATIC)

Fetching tokens...

Contract name:
dgSlots




Optimization enabled
true
Compiler version
v0.7.4+commit.3f05b770




Optimization runs
200
EVM Version
default

Constructor Arguments

0000000000000000000000008562746aeab494b29394577f15e865d45f31438100000000000000000000000000000000000000000000000000000000000000fa000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000400000000000000000000000085697947b9bac8926bfa1e265a220436e8d0ee84

Arg [0] (address) : 0x8562746aeab494b29394577f15e865d45f314381
Arg [1] (uint16) : 250
Arg [2] (uint16) : 15
Arg [3] (uint16) : 8
Arg [4] (uint16) : 4
Arg [5] (address) : 0x85697947b9bac8926bfa1e265a220436e8d0ee84

              

Contract source code

/**
* Submitted for verification at blockscout.com on 2020-10-29 09:20:23.736502Z
*/
// SPDX-License-Identifier: -- 🎲 --
pragma solidity ^0.7.4;
// Slot Machine Logic Contract ///////////////////////////////////////////////////////////
// Author: Decentral Games ([email protected]) ///////////////////////////////////////
// Single Play - Simple Slots - TokenIndex
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, 'SafeMath: addition overflow');
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, 'SafeMath: subtraction overflow');
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, 'SafeMath: multiplication overflow');
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, 'SafeMath: division by zero');
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, 'SafeMath: modulo by zero');
return a % b;
}
}
contract AccessController {
address public ceoAddress;
address public workerAddress;
bool public paused = false;
// mapping (address => enumRoles) accessRoles; // multiple operators idea
event CEOSet(address newCEO);
event WorkerSet(address newWorker);
event Paused();
event Unpaused();
constructor() {
ceoAddress = msg.sender;
workerAddress = msg.sender;
emit CEOSet(ceoAddress);
emit WorkerSet(workerAddress);
}
modifier onlyCEO() {
require(
msg.sender == ceoAddress,
'AccessControl: CEO access denied'
);
_;
}
modifier onlyWorker() {
require(
msg.sender == workerAddress,
'AccessControl: worker access denied'
);
_;
}
modifier whenNotPaused() {
require(
!paused,
'AccessControl: currently paused'
);
_;
}
modifier whenPaused {
require(
paused,
'AccessControl: currenlty not paused'
);
_;
}
function setCEO(address _newCEO) public onlyCEO {
require(
_newCEO != address(0x0),
'AccessControl: invalid CEO address'
);
ceoAddress = _newCEO;
emit CEOSet(ceoAddress);
}
function setWorker(address _newWorker) external {
require(
_newWorker != address(0x0),
'AccessControl: invalid worker address'
);
require(
msg.sender == ceoAddress || msg.sender == workerAddress,
'AccessControl: invalid worker address'
);
workerAddress = _newWorker;
emit WorkerSet(workerAddress);
}
function pause() external onlyWorker whenNotPaused {
paused = true;
emit Paused();
}
function unpause() external onlyCEO whenPaused {
paused = false;
emit Unpaused();
}
}
interface TreasuryInstance {
function getTokenAddress(
uint8 _tokenIndex
) external view returns (address);
function tokenInboundTransfer(
uint8 _tokenIndex,
address _from,
uint256 _amount
) external returns (bool);
function tokenOutboundTransfer(
uint8 _tokenIndex,
address _to,
uint256 _amount
) external returns (bool);
function checkAllocatedTokens(
uint8 _tokenIndex
) external view returns (uint256);
function checkApproval(
address _userAddress,
uint8 _tokenIndex
) external view returns (uint256 approved);
function getMaximumBet(
uint8 _tokenIndex
) external view returns (uint128);
function consumeHash(
bytes32 _localhash
) external returns (bool);
}
interface PointerInstance {
function addPoints(
address _player,
uint256 _points,
address _token,
uint256 _numPlayers,
uint256 _wearableBonus
) external returns (
uint256 newPoints,
uint256 multiplierA,
uint256 multiplierB
);
function addPoints(
address _player,
uint256 _points,
address _token,
uint256 _numPlayers
) external returns (
uint256 newPoints,
uint256 multiplierA,
uint256 multiplierB
);
function addPoints(
address _player,
uint256 _points,
address _token
) external returns (
uint256 newPoints,
uint256 multiplierA,
uint256 multiplierB
);
}
contract dgSlots is AccessController {
using SafeMath for uint128;
uint256 private factors;
TreasuryInstance public treasury;
PointerInstance public pointerContract;
event GameResult(
address _player,
uint8 _tokenIndex,
uint128 _landID,
uint256 indexed _number,
uint128 indexed _machineID,
uint256 _winAmount
);
constructor(
address _treasury,
uint16 factor1,
uint16 factor2,
uint16 factor3,
uint16 factor4,
address _pointerAddress
)
{
treasury = TreasuryInstance(
_treasury
);
require(
factor1 > factor2 + factor3 + factor4,
'Slots: incorrect ratio'
);
factors |= uint256(factor1)<<0;
factors |= uint256(factor2)<<16;
factors |= uint256(factor3)<<32;
factors |= uint256(factor4)<<48;
pointerContract = PointerInstance(
_pointerAddress
);
}
function play(
address _player,
uint128 _landID,
uint128 _machineID,
uint128 _betAmount,
bytes32 _localhash,
uint8 _tokenIndex,
uint256 _wearableBonus
)
public
whenNotPaused
onlyWorker
{
require(
treasury.checkApproval(_player, _tokenIndex) >= _betAmount,
'Slots: exceeded allowance amount'
);
require(
treasury.getMaximumBet(_tokenIndex) >= _betAmount,
'Slots: exceeded maximum bet amount'
);
require(
treasury.checkAllocatedTokens(_tokenIndex) >= getMaxPayout(_betAmount),
'Slots: not enough tokens for payout'
);
treasury.tokenInboundTransfer(
_tokenIndex,
_player,
_betAmount
);
treasury.consumeHash(
_localhash
);
pointerContract.addPoints(
_player,
_betAmount,
treasury.getTokenAddress(_tokenIndex),
1,
_wearableBonus
);
(uint256 _number, uint256 _winAmount) = _launch(
_localhash,
_betAmount
);
if (_winAmount > 0) {
treasury.tokenOutboundTransfer(
_tokenIndex,
_player,
_winAmount
);
}
emit GameResult(
_player,
_tokenIndex,
_landID,
_number,
_machineID,
_winAmount
);
}
function _launch(
bytes32 _localhash,
uint128 _betAmount
)
internal
view
returns (
uint256 number,
uint256 winAmount
)
{
number = getRandomNumber(_localhash) % 1000;
uint256 _numbers = number;
uint8[5] memory _positions = [255, 0, 16, 32, 48];
uint8[10] memory _symbols = [4, 4, 4, 4, 3, 3, 3, 2, 2, 1];
uint256 _winner = _symbols[_numbers % 10];
for (uint256 i = 0; i < 2; i++) {
_numbers = uint256(_numbers) / 10;
if (_symbols[_numbers % 10] != _winner) {
_winner = 0;
break;
}
}
delete _symbols;
delete _numbers;
winAmount = _betAmount.mul(
uint16(
factors>>_positions[_winner]
)
);
}
function getRandomNumber(
bytes32 _localhash
)
private
pure
returns (uint256)
{
return uint256(
keccak256(
abi.encodePacked(
_localhash
)
)
);
}
function getPayoutFactor(
uint8 _position
)
external
view
returns (uint16)
{
return uint16(
factors>>_position
);
}
function getMaxPayout(
uint128 _betSize
)
public
view
returns (uint256)
{
return _betSize.mul(
uint16(
factors>>0
)
);
}
function updateFactors(
uint16 factor1,
uint16 factor2,
uint16 factor3,
uint16 factor4
)
external
onlyCEO
{
require(
factor1 > factor2 + factor3 + factor4,
'Slots: incorrect ratio'
);
factors = uint256(0);
factors |= uint256(factor1)<<0;
factors |= uint256(factor2)<<16;
factors |= uint256(factor3)<<32;
factors |= uint256(factor4)<<48;
}
function updateTreasury(
address _newTreasuryAddress
)
external
onlyCEO
{
treasury = TreasuryInstance(
_newTreasuryAddress
);
}
function updatePointer(address _newPointerAddress)
external
onlyCEO
{
pointerContract = PointerInstance(
_newPointerAddress
);
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_treasury","internalType":"address"},{"type":"uint16","name":"factor1","internalType":"uint16"},{"type":"uint16","name":"factor2","internalType":"uint16"},{"type":"uint16","name":"factor3","internalType":"uint16"},{"type":"uint16","name":"factor4","internalType":"uint16"},{"type":"address","name":"_pointerAddress","internalType":"address"}]},{"type":"event","name":"CEOSet","inputs":[{"type":"address","name":"newCEO","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"GameResult","inputs":[{"type":"address","name":"_player","internalType":"address","indexed":false},{"type":"uint8","name":"_tokenIndex","internalType":"uint8","indexed":false},{"type":"uint128","name":"_landID","internalType":"uint128","indexed":false},{"type":"uint256","name":"_number","internalType":"uint256","indexed":true},{"type":"uint128","name":"_machineID","internalType":"uint128","indexed":true},{"type":"uint256","name":"_winAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[],"anonymous":false},{"type":"event","name":"WorkerSet","inputs":[{"type":"address","name":"newWorker","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ceoAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getMaxPayout","inputs":[{"type":"uint128","name":"_betSize","internalType":"uint128"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"getPayoutFactor","inputs":[{"type":"uint8","name":"_position","internalType":"uint8"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"play","inputs":[{"type":"address","name":"_player","internalType":"address"},{"type":"uint128","name":"_landID","internalType":"uint128"},{"type":"uint128","name":"_machineID","internalType":"uint128"},{"type":"uint128","name":"_betAmount","internalType":"uint128"},{"type":"bytes32","name":"_localhash","internalType":"bytes32"},{"type":"uint8","name":"_tokenIndex","internalType":"uint8"},{"type":"uint256","name":"_wearableBonus","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract PointerInstance"}],"name":"pointerContract","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCEO","inputs":[{"type":"address","name":"_newCEO","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setWorker","inputs":[{"type":"address","name":"_newWorker","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract TreasuryInstance"}],"name":"treasury","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateFactors","inputs":[{"type":"uint16","name":"factor1","internalType":"uint16"},{"type":"uint16","name":"factor2","internalType":"uint16"},{"type":"uint16","name":"factor3","internalType":"uint16"},{"type":"uint16","name":"factor4","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updatePointer","inputs":[{"type":"address","name":"_newPointerAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTreasury","inputs":[{"type":"address","name":"_newTreasuryAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"workerAddress","inputs":[]}]
            

Contract Byte Code

0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80635c975abb116100975780638456cb59116100665780638456cb591461026e578063c26f6d4414610276578063cbd88f481461029c578063fce61514146102a4576100f5565b80635c975abb146101ed57806361d027b31461020957806374044c50146102115780637f51bb1f14610248576100f5565b80633025d9e2116100d35780633025d9e21461017f5780633f4ba83a146101a5578063452f2d8c146101ad57806350bfba99146101e5576100f5565b806307bdfe03146100fa5780630a0f81681461013557806327d7874c14610159575b600080fd5b6101336004803603608081101561011057600080fd5b5061ffff81358116916020810135821691604082013581169160600135166102fe565b005b61013d6103e0565b604080516001600160a01b039092168252519081900360200190f35b6101336004803603602081101561016f57600080fd5b50356001600160a01b03166103ef565b6101336004803603602081101561019557600080fd5b50356001600160a01b03166104db565b61013361054a565b6101d3600480360360208110156101c357600080fd5b50356001600160801b0316610617565b60408051918252519081900360200190f35b61013d61063b565b6101f561064a565b604080519115158252519081900360200190f35b61013d61065a565b6102316004803603602081101561022757600080fd5b503560ff16610669565b6040805161ffff9092168252519081900360200190f35b6101336004803603602081101561025e57600080fd5b50356001600160a01b0316610676565b6101336106e5565b6101336004803603602081101561028c57600080fd5b50356001600160a01b03166107cb565b61013d6108c8565b610133600480360360e08110156102ba57600080fd5b506001600160a01b03813516906001600160801b03602082013581169160408101358216916060820135169060808101359060ff60a0820135169060c001356108d7565b6000546001600160a01b0316331461034b576040805162461bcd60e51b8152602060048201819052602482015260008051602061116e833981519152604482015290519081900360640190fd5b808284010161ffff168461ffff16116103a4576040805162461bcd60e51b8152602060048201526016602482015275536c6f74733a20696e636f727265637420726174696f60501b604482015290519081900360640190fd5b61ffff9390931660109290921b63ffff0000169190911760209190911b65ffff00000000161760309190911b67ffff0000000000001617600255565b6000546001600160a01b031681565b6000546001600160a01b0316331461043c576040805162461bcd60e51b8152602060048201819052602482015260008051602061116e833981519152604482015290519081900360640190fd5b6001600160a01b0381166104815760405162461bcd60e51b815260040180806020018281038252602281526020018061118e6022913960400191505060405180910390fd5b600080546001600160a01b0319166001600160a01b03838116919091179182905560408051929091168252517ff97cbb4246b709036319093e5ff31674b9f6759076d153e1bea1f60392170fc0916020908290030190a150565b6000546001600160a01b03163314610528576040805162461bcd60e51b8152602060048201819052602482015260008051602061116e833981519152604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610597576040805162461bcd60e51b8152602060048201819052602482015260008051602061116e833981519152604482015290519081900360640190fd5b600154600160a01b900460ff166105df5760405162461bcd60e51b81526004018080602001828103825260238152602001806112166023913960400191505060405180910390fd5b6001805460ff60a01b191690556040517fa45f47fdea8a1efdd9029a5691c7f759c32b7c698632b563573e155625d1693390600090a1565b600254600090610635906001600160801b0384169061ffff16610f2a565b92915050565b6004546001600160a01b031681565b600154600160a01b900460ff1681565b6003546001600160a01b031681565b60025460ff82161c919050565b6000546001600160a01b031633146106c3576040805162461bcd60e51b8152602060048201819052602482015260008051602061116e833981519152604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b0316331461072e5760405162461bcd60e51b81526004018080602001828103825260238152602001806111b06023913960400191505060405180910390fd5b600154600160a01b900460ff161561078d576040805162461bcd60e51b815260206004820152601f60248201527f416363657373436f6e74726f6c3a2063757272656e746c792070617573656400604482015290519081900360640190fd5b6001805460ff60a01b1916600160a01b1790556040517f9e87fac88ff661f02d44f95383c817fece4bce600a3dab7a54406878b965e75290600090a1565b6001600160a01b0381166108105760405162461bcd60e51b81526004018080602001828103825260258152602001806111496025913960400191505060405180910390fd5b6000546001600160a01b031633148061083357506001546001600160a01b031633145b61086e5760405162461bcd60e51b81526004018080602001828103825260258152602001806111496025913960400191505060405180910390fd5b600180546001600160a01b0319166001600160a01b03838116919091179182905560408051929091168252517f54841e992da2f7bcaa3127409f02e1849c79072740593c398d6670f65f995fa7916020908290030190a150565b6001546001600160a01b031681565b600154600160a01b900460ff1615610936576040805162461bcd60e51b815260206004820152601f60248201527f416363657373436f6e74726f6c3a2063757272656e746c792070617573656400604482015290519081900360640190fd5b6001546001600160a01b0316331461097f5760405162461bcd60e51b81526004018080602001828103825260238152602001806111b06023913960400191505060405180910390fd5b6003546040805162f887cf60e81b81526001600160a01b038a8116600483015260ff8616602483015291516001600160801b03881693929092169163f887cf0091604480820192602092909190829003018186803b1580156109e057600080fd5b505afa1580156109f4573d6000803e3d6000fd5b505050506040513d6020811015610a0a57600080fd5b50511015610a5f576040805162461bcd60e51b815260206004820181905260248201527f536c6f74733a20657863656564656420616c6c6f77616e636520616d6f756e74604482015290519081900360640190fd5b600354604080516371da23e960e01b815260ff8516600482015290516001600160801b038716926001600160a01b0316916371da23e9916024808301926020929190829003018186803b158015610ab557600080fd5b505afa158015610ac9573d6000803e3d6000fd5b505050506040513d6020811015610adf57600080fd5b50516001600160801b03161015610b275760405162461bcd60e51b81526004018080602001828103825260228152602001806111f46022913960400191505060405180910390fd5b610b3084610617565b6003546040805163c70620b560e01b815260ff8616600482015290516001600160a01b039092169163c70620b591602480820192602092909190829003018186803b158015610b7e57600080fd5b505afa158015610b92573d6000803e3d6000fd5b505050506040513d6020811015610ba857600080fd5b50511015610be75760405162461bcd60e51b81526004018080602001828103825260238152602001806112396023913960400191505060405180910390fd5b600354604080516341d4c74f60e01b815260ff851660048201526001600160a01b038a811660248301526001600160801b0388166044830152915191909216916341d4c74f9160648083019260209291908290030181600087803b158015610c4e57600080fd5b505af1158015610c62573d6000803e3d6000fd5b505050506040513d6020811015610c7857600080fd5b5050600354604080516365afb44f60e01b81526004810186905290516001600160a01b03909216916365afb44f916024808201926020929091908290030181600087803b158015610cc857600080fd5b505af1158015610cdc573d6000803e3d6000fd5b505050506040513d6020811015610cf257600080fd5b50506004805460035460408051630b5a7f2360e31b815260ff871694810194909452516001600160a01b03928316936306804295938c938a93911691635ad3f918916024808301926020929190829003018186803b158015610d5357600080fd5b505afa158015610d67573d6000803e3d6000fd5b505050506040513d6020811015610d7d57600080fd5b5051604080516001600160e01b031960e087901b1681526001600160a01b0394851660048201526001600160801b039093166024840152921660448201526001606482015260848101859052905160a48083019260609291908290030181600087803b158015610dec57600080fd5b505af1158015610e00573d6000803e3d6000fd5b505050506040513d6060811015610e1657600080fd5b506000905080610e268587610f8a565b90925090508015610ebd5760035460408051631894bcc960e11b815260ff871660048201526001600160a01b038c81166024830152604482018590529151919092169163312979929160648083019260209291908290030181600087803b158015610e9057600080fd5b505af1158015610ea4573d6000803e3d6000fd5b505050506040513d6020811015610eba57600080fd5b50505b604080516001600160a01b038b16815260ff861660208201526001600160801b038a8116828401526060820184905291519189169184917f5c4fd4ffc0ec6cec4aab278f45846a19429721cefe83160501316e56e4e826dc919081900360800190a3505050505050505050565b600082610f3957506000610635565b82820282848281610f4657fe5b0414610f835760405162461bcd60e51b81526004018080602001828103825260218152602001806111d36021913960400191505060405180910390fd5b9392505050565b6000806103e8610f99856110e7565b81610fa057fe5b06915081610fac61110b565b506040805160a08101825260ff81526000602080830191909152601092820192909252606081019190915260306080820152610fe6611129565b506040805161014081018252600480825260208201819052918101829052606081019190915260036080820181905260a0820181905260c0820152600260e082018190526101008201526001610120820152600081600a8506600a811061104957fe5b602002015160ff16905060005b600281101561109357600a850494508183600a8706600a811061107557fe5b602002015160ff161461108b5760009150611093565b600101611056565b5061109c611129565b9150600093506110da8382600581106110b157fe5b602002015160ff16600254901c61ffff16886001600160801b0316610f2a90919063ffffffff16565b9450505050509250929050565b60408051602080820193909352815180820384018152908201909152805191012090565b6040518060a001604052806005906020820280368337509192915050565b604051806101400160405280600a90602082028036833750919291505056fe416363657373436f6e74726f6c3a20696e76616c696420776f726b65722061646472657373416363657373436f6e74726f6c3a2043454f206163636573732064656e696564416363657373436f6e74726f6c3a20696e76616c69642043454f2061646472657373416363657373436f6e74726f6c3a20776f726b6572206163636573732064656e696564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77536c6f74733a206578636565646564206d6178696d756d2062657420616d6f756e74416363657373436f6e74726f6c3a2063757272656e6c7479206e6f7420706175736564536c6f74733a206e6f7420656e6f75676820746f6b656e7320666f72207061796f7574a26469706673582212207031318e75324fe08e87b485f322707f926484ab74e28101dfa838d4fe5adc8b64736f6c63430007040033